English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This article introduces the usage of the mkdir command to create directories and subdirectories under Linux. Now we are going to learn how to create directories in the Linux system. In Linux, we can use the mkdir command. Mkdir is an abbreviation for 'make directory'.
What is mkdir
Mkdir is a command used to create directories in the Linux system. This command is a built-in command.
Run the mkdir command
You can directly type mkdir in your console to use it.
$ mkdir
By default, running the mkdir command without any parameters will create a directory in the current directory. Here is a reference example:
From the above figure, we can see that we have created a directory named office. When we run the mkdir command, we are located in /home/the pungki directory. Therefore, the new directory office is created at/home/Under the pungki directory. If we use the absolute path - For example:/usr/local - Then, Linux will be /usr/Create a directory under the local directory.
When Linux finds that the directory to be created already exists, then Linux will prompt us that Linux cannot create it.
Another primary condition for creating a directory is that you must have access permissions under the target path where you want to create the directory. When you cannot obtain the permissions, mkdir will report this error.
To create multiple directories
We can also create multiple directories at the same time. For example, if the directories we want to create are ubuntu, redhat, and slackware, then the syntax will be like this:
$ mkdir ubuntu redhat slackware
to add a directory containing subdirectories [Translation note: recursively create directories]
When you need to create a directory that contains subdirectories, you need to use -p parameter. If mkdir cannot find the parent directory, this parameter will first help create the parent directory. For example, if we want to create a directory named letter, which contains a subdirectory important under it, then the syntax will be like this:
$ mkdir -p letter/important
to set access permissions
Using -Using the m parameter, we can set permissions for the new directory to be generated. For example:
$ mkdir -m=r-- letter
The above command will create a directory named letter and grant read-only permissions to the directory owner, group, and other users for the directory
to print the process information of creating a directory
If we want to view information, we can use -v parameter to achieve. For example:
$ mkdir -v ubuntu redhat slackware
Summary
The mkdir command also belongs to one of the most basic commands, and this command must be mastered by friends who want to learn Linux. As usual, you can type man mkdir or mkdir --help to display the manual page of mkdir and more in-depth discussions.
That's all for the content of this article, I hope it will be helpful to everyone's learning, and I also hope everyone will support the Shouting Tutorial more.
Declaration: The content of this article is from the Internet, the copyright belongs to the original author, the content is contributed and uploaded by Internet users spontaneously, this website does not own the copyright, does not edit manually, and does not assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email to report abuse, and provide relevant evidence. Once verified, this site will immediately delete the content suspected of infringement.)