Linux Basic Command Learning mkdir (3)

Source: Internet
Author: User

Mkdir

1. Command Format

mkdir [Options ] Catalogue .. .

2 . Command Functions

by mkdir command can be implemented at the specified location to create aDirName (the specified file name)the named folder or directory. The user who creates the folder or directory must have write permissions to the parent folder of the folder that is created. Also, the folders that are created(Catalogue)cannot be associated with its parent directory(that is, the parent folder)the name of the file in the same directory cannot have the same name(Case Sensitive).

3. command parameters and instances

-M,--mode= mode, set permissions<Mode> (similarchmod), but notrwxrwxrwxminusumask

  -P,--parentscan be a path name. At this point, if some directories in the path do not yet exist , Plusafter this option,The system will automatically set up directories that do not yet exist.,that is, once you canCreate multiple directories; 

-V,--verbose each time a new directory is created Tips Information

--HELP Display this help message and exit

--version output version information and exit

#######################################################################

Example 1: Create an empty directory

[[Email protected] data]# mkdir test1[[email protected] data]# lltotal  40-rw-r--r--.  1 root root    0 Nov 14  2012  Admin.log-rw-r--r--.  1 root root   15 Nov 13 04:09  A.txt-rw-r--r--.  1 root root   31 Nov 13 04:09  B.txt-rw-r--r--.  1 root root   81 Nov 13 04:09  C.txtdrwxr-xr-x. 2 root root 4096 nov 13 04:58 dcpdrwxr-xr-x. 2  root root 4096 nov 13 03:49 dongdrwxr-xr-x. 2 root root  4096 Nov 13 05:03 jimdrwxr-xr-x. 2 root root 4096 Nov  13 05:03 lucy-rw-r--r--.  1 root root    0 Nov 13  04:13 pbc.bmpdrwxr-xr-x. 3 root root&Nbsp;4096 nov 13 05:03 teacherdrwxr-xr-x. 2 root root 4096 nov  13 05:04 test1-rw-r--r--.  1 root root    0 nov 13  04:48 test.txtdrwxr-xr-x. 2 root root 4096 nov 13 04:08 you [[email protected] data]#


Example 2 : recursively Create multiple directories  

Command:

< /span>     mkdir -p /data/test2/ Test22  /data/team

[[Email protected] data]# mkdir -p /data/test2/test22  /data/team[[email  protected] data]# lltotal 48-rw-r--r--.  1 root root     0 nov 14  2012 admin.log-rw-r--r--.  1 root root    15 nov 13 04:09 a.txt-rw-r--r--.  1 root root   31  nov 13 04:09 b.txt-rw-r--r--.  1 root root   81 nov  13 04:09 c.txtdrwxr-xr-x. 2 root root 4096 nov 13 04:58  dcpdrwxr-xr-x. 2 root root 4096 nov 13 03:49 dongdrwxr-xr-x.  2 root root 4096 Nov 13 05:03 jimdrwxr-xr-x. 2 root  Root 4096 nov 13 05:03 lucy-rw-r--r--.  1 root root     0 nov 13 04:13 pbc.bmpdrwxr-xr-x. 3 root root 4096 nov 13 05:03 teacherdrwxr-xr-x.  2 root root 4096 nov 13 05:06 teamdrwxr-xr-x. 2 root root  4096 nov 13 05:04 test1drwxr-xr-x. 3 root root 4096 nov  13 05:06 test2-rw-r--r--.  1 root root    0 nov 13  04:48 test.txtdrwxr-xr-x. 2 root root 4096 nov 13 04:08 you [[email protected] data]# tree /data/data├── admin.log├── a.txt├── b.txt├──  c.txt├── dcp├── dong├── jim├── lucy├── pbc.bmp├── teacher│    └── john├── team├── test1├── test2│   └── test22├──  test.txt└── you    └── lol.txt 11 directories, 7 files[[ Email protected] data]# 

Example 3 : Create a permission of 777 the directory  

Command:

< /span>     mkdir -m 777 test3     

[[email protected] data]# mkdir -m 777 super[[email protected] data]#  lltotal 52-rw-r--r--.  1 root root    0 Nov 14   2012 admin.log-rw-r--r--.  1 root root   15 Nov 13  04:09 a.txt-rw-r--r--.  1 root root   31 Nov 13 04:09  B.txt-rw-r--r--.  1 root root   81 Nov 13 04:09  C.txtdrwxr-xr-x. 2 root root 4096 nov 13 04:58 dcpdrwxr-xr-x. 2  root root 4096 nov 13 03:49 dongdrwxr-xr-x. 2 root root  4096 Nov 13 05:03 jimdrwxr-xr-x. 2 root root 4096 Nov  13 05:03 lucy-rw-r--r--.  1 root root    0 Nov 13  04:13 pbc.bmpdrwxrwxrwx. 2 root root 4096 nov 13 05:09 superdrwxr-xr-x. 3 root root  4096 nov 13 05:03 teacherdrwxr-xr-x. 2 root root 4096 nov 13  05:06 teamdrwxr-xr-x. 2 root root 4096 Nov 13 05:04  Test1drwxr-xr-x. 3 root root 4096 nov 13 05:06 test2-rw-r--r--.  1  root root    0 nov 13 04:48 test.txtdrwxr-xr-x. 2  root root 4096 nov 13 04:08 you[[email protected] data]#


Example Five: looping through the creation of a directory and displaying a message

Command:

MKDIR-VP /test/try/{a,b,c}/test/test1/a/test/test2/{e,f,g}

[[email protected] data]# [[email protected] data]# mkdir -vp /test/ try/{a,b,c} /test/test1/a /test/test2/{e,f,g}mkdir: created directory  '/test/try ' mkdir: created directory  '/test/try/a ' mkdir: created directory  '/test/try/b ' mkdir: created directory  '/test/try/c ' mkdir: created directory  '/test/test1 ' mkdir: created directory  '/test/test1/a ' mkdir: created directory  '/test/test2 ' mkdir: created directory  '/test/test2/e ' mkdir: created directory  '/test/test2/f ' mkdir: created directory  '/test/test2/g ' [[email protected] data]# tree / test/test├── a├── b├── c├── test1│   └── a├── test2│    ├── e│   ├── f│   └── g└── try     ├── a    ├── b    └── c 13 directories, 0 files[[email  protected] data]#



This article is from the "Qin Xian son" blog, please make sure to keep this source http://youdong.blog.51cto.com/3562886/1718141

Linux Basic Command Learning mkdir (3)

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.