Home> System Tutorial> LINUX> body text

Detailed explanation and example demonstration of Linux command mkdir

PHPz
Release: 2024-03-20 09:51:04
Original
1162 people have browsed it

Linux command mkdir detailed explanation and example demonstration

In the Linux system, themkdircommand is used to create directories and is highly flexible and practical. sex. Through themkdircommand, users can quickly create a directory structure to facilitate management of files and data. This article will introduce the use of themkdircommand in detail and give specific code examples to demonstrate its functionality.

1.mkdirCommand introduction

mkdiris the abbreviation of "make directory" in English and is used to create a new directory. Its basic format is:

mkdir [option] directory name
Copy after login

2.mkdirCommon options for the command

  • -m: Specify the permissions for the new directory, the default is777
  • -p: Create directories recursively, that is, you can create multi-layer directories at once

3.mkdirCommand example demonstration

3.1 Create a single directory

mkdir mydir
Copy after login

The above command will create a directory named Is the new directory ofmydir.

3.2 Create multi-layer directories

mkdir -p mydir1/mydir2/mydir3
Copy after login

The above command will recursively create themydir1directory and recursively create it in itmydir2directory, and then recursively create themydir3directory inmydir2.

3.3 Create a directory with specified permissions

mkdir -m 755 mydir
Copy after login

The above command will create a new directory with permissions755mydir.

3.4 Create multiple directories at the same time

mkdir dir1 dir2 dir3
Copy after login

The above command will createdir1,dir2,# at the same time ##dir3Three directories.

3.5 Create a directory with spaces

mkdir 'my directory'

        
Copy after login
The above command will create a directory named

my directory, which can be passed Use single or double quotes to handle directory names with spaces.

Conclusion

Through the above example demonstration, we can see the flexibility and practicality of the

mkdircommand. It can create directory structures quickly and easily, helping us better manage files and data. In daily Linux system management, themkdircommand is an essential tool. I hope this article will help you understand and master themkdircommand.

The above is the detailed content of Detailed explanation and example demonstration of 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!