Home >System Tutorial >LINUX >How to create a directory using the Linux command mkdir
How to use the Linux command mkdir to create a directory
In a Linux system, use the mkdir command to create a directory. mkdir is the abbreviation of make directory. This command can easily create a new directory in the file system. The following will introduce in detail how to use the mkdir command to create a directory and provide specific code examples.
The basic syntax of the mkdir command is as follows:
mkdir [OPTION] DIRECTORY...
Among them, [OPTION] can Select parameters. DIRECTORY is the name of the directory to be created. Multiple directories can be created at the same time. Multiple directory names are separated by spaces.
To create a single directory, just enter the following command in the terminal:
mkdir directory_name
For example, to create a single directory in To create a directory named test under the current path, you can enter the following command:
mkdir test
If you want to create multiple directories at the same time, You can separate the directory names with spaces and list them in the command:
mkdir directory1 directory2 directory3
For example, to create three directories test1, test2 and test3 under the current path, you can enter The following command:
mkdir test1 test2 test3
If you want to create a multi-level directory, you can use the -p parameter, which will automatically create an intermediate directory Missing directory:
mkdir -p directory1/directory2/directory3
For example, to create a directory named dir1 that contains a subdirectory named dir2, you can enter the following command:
mkdir -p dir1/dir2
mkdir --help
The above are the specific steps to create a directory using the Linux command mkdir and code examples. With these simple commands, you can easily create new directories in your Linux system and improve work efficiency.
The above is the detailed content of How to create a directory using the Linux command mkdir. For more information, please follow other related articles on the PHP Chinese website!