每天一命令(3) mkdir (make directories) 1分钟

来源:互联网 发布:如何删除win10网络共享 编辑:程序博客网 时间:2024/06/06 02:27

mkdir (make directories)

man mkdir 查看命令使用

命令描述

NAME       mkdir - make directoriesSYNOPSIS       mkdir [OPTION]... DIRECTORY...DESCRIPTION       Create the DIRECTORY(ies), if they do not already exist.       Mandatory arguments to long options are mandatory for short options too.       -m, --mode=MODE              set file mode (as in chmod), not a=rwx - umask       -p, --parents              no error if existing, make parent directories as needed       -v, --verbose              print a message for each created directory       -Z, --context=CTX              set the SELinux security context of each created directory to CTX       --help display this help and exit       --version              output version information and exit

创建单个目录mkdir html

[root@guofeng ~]# mkdir html[root@guofeng ~]# lltotal 68-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt-rw-r--r--  1 root root   479 Jun  7 06:44 dump.rdb-rw-r--r--  1 root root     0 May 17 07:00 EOFdrwxr-xr-x  2 root root  4096 Jun  7 18:04 html-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog

创建多个目录 mkdir index css images

[root@guofeng ~]# mkdir index css images[root@guofeng ~]# lltotal 80-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txtdrwxr-xr-x  2 root root  4096 Jun  7 18:05 css-rw-r--r--  1 root root   479 Jun  7 06:44 dump.rdb-rw-r--r--  1 root root     0 May 17 07:00 EOFdrwxr-xr-x  2 root root  4096 Jun  7 18:04 htmldrwxr-xr-x  2 root root  4096 Jun  7 18:05 imagesdrwxr-xr-x  2 root root  4096 Jun  7 18:05 index-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog

创建多个目录第二种方式 mkdir {js,common,plugin}

[root@guofeng ~]# mkdir {js,common,plugin}[root@guofeng ~]# lltotal 92-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txtdrwxr-xr-x  2 root root  4096 Jun  7 18:05 commondrwxr-xr-x  2 root root  4096 Jun  7 18:05 css-rw-r--r--  1 root root   479 Jun  7 06:44 dump.rdb-rw-r--r--  1 root root     0 May 17 07:00 EOFdrwxr-xr-x  2 root root  4096 Jun  7 18:04 htmldrwxr-xr-x  2 root root  4096 Jun  7 18:05 imagesdrwxr-xr-x  2 root root  4096 Jun  7 18:05 index-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslogdrwxr-xr-x  2 root root  4096 Jun  7 18:05 jsdrwxr-xr-x  2 root root  4096 Jun  7 18:05 plugin

创建多层级目录 mkdir -p /web/static/html/css

[root@guofeng ~]# mkdir -p /web/static/html/css[root@guofeng /]# cd web[root@guofeng web]# lltotal 4drwxr-xr-x 3 root root 4096 Jun  7 18:13 static[root@guofeng web]# cd static/[root@guofeng static]# lltotal 4drwxr-xr-x 3 root root 4096 Jun  7 18:13 html[root@guofeng static]# cd html[root@guofeng html]# lltotal 4drwxr-xr-x 2 root root 4096 Jun  7 18:13 css[root@guofeng html]# cd ss-bash: cd: ss: No such file or directory[root@guofeng html]# cd css[root@guofeng css]# 

创建文件,显示创建过程mkdir -pv htm/index/css

[root@guofeng ~]# mkdir -pv htm/index/cssmkdir: created directory `htm'mkdir: created directory `htm/index'mkdir: created directory `htm/index/css'[root@guofeng ~]# 

创建目录并且设置访问权限 mkdir -m 777 test

[root@guofeng ~]# mkdir -m 777 test[root@guofeng ~]# lltotal 96-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txtdrwxr-xr-x  2 root root  4096 Jun  7 18:05 commondrwxr-xr-x  2 root root  4096 Jun  7 18:05 css-rw-r--r--  1 root root   479 Jun  7 06:44 dump.rdb-rw-r--r--  1 root root     0 May 17 07:00 EOFdrwxr-xr-x  3 root root  4096 Jun  7 18:18 htmdrwxr-xr-x  2 root root  4096 Jun  7 18:05 imagesdrwxr-xr-x  2 root root  4096 Jun  7 18:05 index-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslogdrwxr-xr-x  2 root root  4096 Jun  7 18:05 jsdrwxr-xr-x  2 root root  4096 Jun  7 18:05 plugindrwxrwxrwx  2 root root  4096 Jun  7 18:22 test[root@guofeng ~]# 
0 0
原创粉丝点击