Home  >  Article  >  System Tutorial  >  How to create a directory using the Linux command mkdir

How to create a directory using the Linux command mkdir

王林
王林Original
2024-03-19 14:48:041181browse

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.

1. Basic syntax

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.

2. Create a single directory

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

3. Create multiple directories

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

4. Create a multi-level directory

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

5. View the help information

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn