Home > Article > Operation and Maintenance > Detailed explanation of mkdir command in Linux
Mkdir is a command used to create directories under Linux systems. This command is a built-in command. Next, I will share with you the detailed explanation of the Linux mkdir command through this article. Friends who are interested should take a look at it.
mkdir command is used to create directories. This command creates a directory named by dirname. If no pathname is added in front of the directory name, the directory specified by dirname will be created in the current directory; if an existing path is given, a specified directory will be created in that directory. When creating a directory, make sure that the newly created directory does not have the same name as the file in the directory where it is located.
Note: When creating files, do not store all files in the main directory. You can create subdirectories to organize files more effectively. It's best to use consistent naming to distinguish files and directories. For example, a directory name can begin with an uppercase letter so that it appears first in directory listings.
A subdirectory should contain files of similar type or purpose. For example, you might create a subdirectory that contains all your database files, another subdirectory that contains your spreadsheet files, another subdirectory that contains your word processing documents, and so on. Directories are also files. They follow the same naming rules as ordinary files, and a directory can be uniquely specified using the full path.
Syntax
mkdir (选项)(参数)
Options
-Z:设置安全上下文,当使用SELinux时有效; -m<目标属性>或--mode<目标属性>建立目录的同时设置目录的权限; -p或--parents 若所要建立目录的上层目录目前尚未建立,则会一并建立上层目录; --version 显示版本信息。
Parameters
Directory: Specify the directory list to be created. Multiple directories are separated by spaces.
Example
Create a subdirectory test under the directory /usr/meng
, and only the file owner can read, write and execute Permissions, others do not have permission to access
mkdir -m 700 /usr/meng/test
Create bin and the os_1 directory under bin in the current directory, and set the permissions to the file owner to read, write, and execute, in the same group Users can read and execute, other users have no access rights
mkdir -p-m 750 bin/os_1
Summary
The above is the detailed content of Detailed explanation of mkdir command in Linux. For more information, please follow other related articles on the PHP Chinese website!