The mkdir of Linux commands

Source: Internet
Author: User
Tags parent directory

1. Environmental description

centos6.7,2.6.32-573.el6.x86_64

2, man mkdir

NAM mkdir-make Directories

Synopsis//outline, abstract, understood as the basic grammar can bemkdir [OPTION] ... DIRECTORY ... DESCRIPTION Create The DIRECTORY (ies), iftheyDo not already exist. //If the directory does not exist, create them, and note that you can single or multiple
Mandatory arguments to long options is Mandatory for short options too.
This sentence is rather awkward, for the long option (--mode) must have parameters (--mode 777, said this 777), for the short option (abbreviation,-m) also have, feel is nonsense ah
That is, whether you are using--mode or-M, with parameter 777,751 and so on, and must take, and then understand that the point isThis command has only one parameter and no default value, you have to specify. -M,--mode=mode set file mode (as in chmod), not A=rwx-umask
//What does that mean? What is not a=rwx-umask?
-P,--parents no error if existing, make parent directories as needed//automatic creation of the parents directory, even if the parent directory exists and does not error, recursive creation Build Catalog
-V,--verbose print a message for each created directory//verbose: verbose, verbose, print out the details of the created directory -Z,--context=ctx set the SELinux security context of each created directory to CTX
This is basically useless because we usually turn off SELinux--help Display this help and exit--version output version information a nd exit

3. Example 1

(1) #mkdir-M 751 Dir1

Drwxr-x--x 2 root root 4096 Apr 3 12:14 Dir1

(2) #mkdir--mode a=rwx-w Dir2

Dr-xr-xr-x 2 root root 4096 Apr 3 12:16 Dir2

(3) #mkdir-M u=rw-,g=r--, o=---dir3

Drw-r-----2 root root 4096 Apr 3 12:17 dir3

(4) #mkdir-M u=-wx dir4

D---rwxrwx 2 root root 4096 Apr 3 12:19 DIR4

(5) #umask

0022

(6) #mkdir-M o=r--dir5

drwxrwxr--2 root root 4096 Apr 3 12:25 DIR5

(7) #mkdir DIR6

Drwxr-xr-x 2 root root 4096 Apr 3 12:28 DIR6

Now you should understand what not a=rmw-umask mean! It means that Umask has no effect here! Of course no effect, no nonsense, umask is the default Ah, all set mode, it certainly should not work ah.

4. Example 2

#mkdir-PV Test1/{test2,test3/{test4,test5}}

mkdir:created directory ' test1 '
mkdir:created directory ' Test1/test2 '
mkdir:created directory ' Test1/test3 '
mkdir:created directory ' Test1/test3/test4 '
mkdir:created directory ' Test1/test3/test5 '

#tree test1

Test1
|--test2
'--test3
|--test4
'--TEST5

4 directories, 0 files

Create a multilevel complex directory with the-p parameter and {}

The mkdir of Linux commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.