The mkdir command in a Linux system is used to create a directory of the specified name. Full name is Mkdir-make directories
Command format:
mkdir [OPTION] ... DIRECTORY ...
Parameters:
-M,--mode=mode set file mode (as in chmod), not A=rwx-umask
Configure permissions for the folder.
-P,--parents no error if existing, make parent directories as needed
Help you to directly create the desired directory (including the upper directory) recursively.
-V,--verbose print a message for each created directory
Output information
RmDir is the command to delete the "empty" directory
Example: Creating an empty Directory
[Email protected] ~]# CD/ZDW [[email protected] zdw]# mkdir test1 Create a new directory named test1 [[email protected] zdw]# Lstest1[[email protected] zdw]# lltotal 4drwxr-xr-x 2 root root 4096 Apr 2 21:26 test1
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/7E/6F/wKioL1b_ybPTlBccAAElTsoYFXU080.jpg "title=" 5.jpg " Width= "730" height= "163" border= "0" hspace= "0" vspace= "0" style= "width:730px;height:163px;" alt= "wkiol1b_ Ybptlbccaaeltsoyfxu080.jpg "/>
Example: Creating Multiple directories recursively
[[email protected] zdw]# mkdir test2/test3/test4/test5mkdir: cannot create directory ' test2/test3/test4/test5 ': no such file or directory The above hints indicate that this directory cannot be created directly [[email protected] zdw]# mkdir -p test2/test3/test4/test5 Join the-p parameter to create a multi-level directory yourself [[email protected] zdw]# ll Verification total 8drwxr-xr-x 2 root root 4096 apr 2 21:26 test1drwxr-xr-x 3 root root 4096 apr 2 21:32 test2[[email There's test3total 4drwxr-xr-x under protected] zdw]# ll /test2 test2. 3 root root 4096 Apr 2 21:31 test3[[email protected] There's test4total 4drwxr-xr-x 3 root under Zdw]# ll /test2/test3 test3. root 4096 apr&nBsp; 2 21:31 test4
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/7E/72/wKiom1b_yqbTPC38AAMpg_pg0-U594.jpg "title=" 6.jpg " Width= "730" height= "199" border= "0" hspace= "0" vspace= "0" style= "WIDTH:730PX;HEIGHT:199PX;" alt= "wkiom1b_ Yqbtpc38aampg_pg0-u594.jpg "/>
Example: displaying information when creating a table of contents
Drwxr-xr-x 3 root root 4096 Apr 2 21:31 test4[[email protected] zdw]# MKDIR-VP t/t1 Add-v parameter to display information mkdir:created dir Ectory ' t ' mkdir:created directory ' t/t1 '
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7E/72/wKiom1b_y42zNpK7AADKDEDzl4A624.jpg "title=" 7.jpg " alt= "Wkiom1b_y42znpk7aadkdedzl4a624.jpg"/>
Example: Create a directory with permissions of Rwx--x--x
[[email protected] zdw]# mkdir-m 711 zzzzz Join-m parameter, set permissions, rwx respectively corresponding 421[[email protected] zdw]# lltotal 16drwxr-xr-x 3 R oot root 4096 Apr 2 21:37 tdrwxr-xr-x 2 root root 4096 Apr 2 21:26 test1drwxr-xr-x 3 root root 4096 Apr 2 21:32 test2dr Wx--x--x 2 root root 4096 APR 2 21:42 zzzzz has seen zzzzz directory with permission 711
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/7E/72/wKiom1b_zRzANJzOAAGy992Xnr4518.jpg "title=" 8.jpg " Width= "730" height= "173" border= "0" hspace= "0" vspace= "0" style= "width:730px;height:173px;" alt= "wkiom1b_ Zrzanjzoaagy992xnr4518.jpg "/>
Example: Delete an empty directory
[[email protected] zdw]# rmdir zzzzz use RmDir, followed by directory name [[email protected] zdw]# lltotal 12drwxr-xr-x 3 root root 409 6 Apr 2 21:37 tdrwxr-xr-x 2 root root 4096 Apr 2 21:26 test1drwxr-xr-x 3 root root 4096 Apr 2 21:32 test2
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/7E/72/wKiom1b_zfqgfFMRAAF9Q2fVxuI029.jpg "title=" 9.jpg " alt= "Wkiom1b_zfqgffmraaf9q2fvxui029.jpg"/>
Example: Deleting a test2/test3/test4/test5 directory
[[email protected] zdw]# rmdir-p TEST2/TEST3/TEST4/TEST5 Join the-p parameter, along with the upper empty directory also delete [[email protected] zdw]# lltotal 8drwxr-xr- X 3 root root 4096 Apr 2 21:37 tdrwxr-xr-x 2 root root 4096 Apr 2 21:26 test1
650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M02/7E/6F/wKioL1b_z-WC31KVAAKWWb1rcoU888.jpg "title=" 10.jpg "Width=" 730 "height=" 292 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:730px;height:292px; "alt=" wkiol1b_ Z-wc31kvaakwwb1rcou888.jpg "/>
Note: rmdir can only delete empty directories, that is, the deleted directory can not exist in other directories or folders. If you want to remove everything from all directories, you must use "Rm-r test".
This article is from the blog "Write to Yourself", so be sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1759636
Linux mkdir Commands