This article describes the use of the mkdir command to create directories and subdirectories under Linux, and now we want to learn to create directories under Linux systems. Under Linux, we can use the mkdir command. Mkdir is the abbreviation for "Make directory".
What's mkdir?
Mkdir is a command to create a directory under a Linux system. This command belongs to the built-in command.
Run mkdir command
You can use it by typing mkdir directly in your console.
By default, running the mkdir command with no parameters creates a directory in the current directory. The following is a reference example:
As shown in the figure above, we created a directory called Office. When we run the mkdir command, we are in the/home/pungki directory. So this new directory office is created in the/home/pungki directory. If we use an absolute path-for example,/usr/local-Linux will create a directory under the/usr/local directory.
When Linux discovers that the directory you want to create already exists, Linux prompts us that Linux cannot create it.
Another prerequisite for creating a directory is that you must have access rights under the target path where you want to create the directory. MKDIR will report this error when you cannot get permission.
Create multiple Catalogs
We can also create multiple catalogs at the same time. For example, we want to create a directory with Ubuntu, Redhat and Slackware. Then the grammar will look like this:
$ mkdir Ubuntu Redhat Slackware
Add a directory containing subdirectories [to create a directory recursively]
When you want to create a directory containing subdirectories, you need to use the-p argument. If mkdir cannot find the parent directory, this parameter will first help create the parent directory. For example, we want to create a directory named letter, which contains subdirectories important in its directory. Then the grammar will look like this:
$ mkdir-p Letter/important
Set access Permissions
With the-m parameter, we can set permissions for the new directory that will be generated. Examples are as follows:
The above command creates a directory named letter and gives read-only access to directory owners, user groups, and other users for that directory
Print process information for creating a directory
If we want to view the information, we can use the-v argument to implement it. Examples are as follows:
$ mkdir-v Ubuntu Redhat Slackware
Summarize
The Mkdir command is also one of the most basic commands that must be mastered for a friend who wants to learn Linux. As always, you can type man mkdir or mkdir--help to display the MkDir manual page and explore more deeply.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.