mkdir

命令说明:

新建目录

语法:

mkdir [-mp] 目录名称

参数:

-m :配置文件的权限,直接设置,不需要看默认权限(umask

-p :帮助你直接将所需要的目录(包括上层目录)递归创建起来

命令实践:

[root@yubinghost ~]# cd /tmp

[root@yubinghost tmp]# mkdir test

[root@yubinghost tmp]# mkdir -p test1/test2/test3/test4

[root@yubinghost tmp]# umask       查看默认权限umask

0022

[root@yubinghost tmp]# ll

total 16

drwx------ 2 root root 4096 Apr  7 11:18 ssh-lEggct3110

drwxr-xr-x 2 root root 4096 Apr  7 12:49 test

drwxr-xr-x 3 root root 4096 Apr  7 12:49 test1

-rw-r--r-- 1 root root    0 Apr  5 14:54 test.txt

-rw-r--r-- 1 root root    0 Apr  7 11:37 yubing

[root@yubinghost tmp]# mkdir -m 744 test2       配置文件的权限

[root@yubinghost tmp]# ll

total 20

drwx------ 2 root root 4096 Apr  7 11:18 ssh-lEggct3110

drwxr-xr-x 2 root root 4096 Apr  7 12:49 test

drwxr-xr-x 3 root root 4096 Apr  7 12:49 test1

drwxr--r-- 2 root root 4096 Apr  7 12:50 test2

-rw-r--r-- 1 root root    0 Apr  5 14:54 test.txt

-rw-r--r-- 1 root root    0 Apr  7 11:37 yubing

[root@yubing ~]# mkdir yubing     创建新目录

[root@yubing ~]# ll

total 64

-rw------- 1 root root   887 Apr  7 01:47 anaconda-ks.cfg

-rw-r--r-- 2 root root   255 Jan  6  2007 crontab1

lrwxrwxrwx 1 root root    12 Apr  8 04:06 crontab2 -> /etc/crontab

-rw-r--r-- 1 root root 23947 Apr  7 01:47 install.log

-rw-r--r-- 1 root root  3619 Apr  7 01:46 install.log.syslog

drwxr-xr-x 2 root root  4096 Apr 12 06:13 yubing

[root@yubing ~]# mkdir -p /yu/bing/first直接将所需要的目录(包括上层目录)递归创建起来

[root@yubing yubing]# cd /yu

total 8

[root@yubing yu]# ll

drwxr-xr-x 3 root root 4096 Apr 12 06:14 bing

[root@yubing yu]# cd bing

[root@yubing bing]# ll

total 8

drwxr-xr-x 2 root root 4096 Apr 12 06:14 first

[root@yubing /]# mkdir -pv /yu/bing/first   加了-v参数,会把详细过程显示出来

mkdir: created directory `/yu'

mkdir: created directory `/yu/bing'

mkdir: created directory `/yu/bing/first'