Home> System Tutorial> LINUX> body text

How to create a directory using the Linux command mkdir

王林
Release: 2024-03-19 14:48:04
Original
1138 people have browsed it

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...
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

For example, to create three directories test1, test2 and test3 under the current path, you can enter The following command:

mkdir test1 test2 test3
Copy after login

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
Copy after login

For example, to create a directory named dir1 that contains a subdirectory named dir2, you can enter the following command:

mkdir -p dir1/dir2
Copy after login

5. View the help information

mkdir --help
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!