1. Command format
mkdir [option] Dir...
Second, the command parameters
-m, --mode =mode, set permissions <mode> (similar to chmod) instead of rwxrwxrwx minus umask
-p, --parents can be a pathname. At this time, if some directories in the path do not exist yet, after adding this option, the system will automatically create those directories that do not exist, that is, multiple directories can be created at one time;
-v, --verbose creates a new directory each time Both display information
--help display this help information and exit
--version output version information and exit
3. Command example
1. Create a directory
Command: mkdir test1
output:
[root@localhost soft]# cd test [root@localhost test]# mkdir test1 [root@localhost test]# ll Total 4drwxr -xr-x 2 root root 4096 10 - 25 17 : 42 test1 [root@localhost test]#
2. Create multiple directories recursively
Command: mkdir -p test2/test22
output:
[root@localhost test]# mkdir -p test2/test22 [root@localhost test]# ll Total 8drwxr -xr-x 2 root root 4096 10 - 25 17 : 42 test1 drwxr-xr-x 3 root root 4096 10-25 17:44 test2 [root@localhost test]# cd test2/ [root@localhost test2]# ll Total 4drwxr -xr-x 2 root root 4096 10 - 25 17 : 44 test22
3. Create a directory with permissions 777
Command: mkdir -m 777 test3
output:
[root@localhost test]# mkdir -m 777 test3 [root@localhost test]# ll Total 12drwxr -xr-x 2 root root 4096 10 - 25 17 : 42 test1 drwxr-xr-x 3 root root 4096 10-25 17:44 test2 drwxrwxrwx 2 root root 4096 10-25 17:46 test3
4. Create a new directory and display information
Command: mkdir -v test4
output:
[root@localhost test]# mkdir -v test4 mkdir : directory "test4" created [root@localhost test]# mkdir -vp test5/test5-1 mkdir : created directory "test5" mkdir : created directory " test5 /test5-1 "
5. One command to create the directory structure of the project
Reference: http://www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.html
Command:
mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{ info,product},service/deploy/{info,product}}
output:
[root@localhost test]# mkdir -vp scf/{lib/,bin/,doc/{ info ,product},logs/{ info ,product},service/deploy/{ info ,product}} mkdir : directory created "scf" mkdir : directory "scf/ lib" created mkdir : directory "scf/ bin" created mkdir : directory "scf/ doc" created mkdir : directory "scf/doc/ info " created mkdir : directory created "scf/doc/ product" mkdir : Directory "scf/ logs" created mkdir : Directory "scf/logs/ info " created mkdir : Directory "scf/logs/ product" created mkdir: directory "scf/ service" created mkdir : directory "scf/service/ deploy" created mkdir : directory "scf/service/deploy/ info " created mkdir : directory "scf/service/deploy/ product" created [root@localhost test]# tree scf/ scf/ |-- bin |-- doc | |-- info | `-- product |-- lib |-- logs | |-- info | `-- product `-- service `-- deploy |-- info `-- product 12 directories, 0 files