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

mkdir (make directories)

man mkdir 查看命令使用

命令描述

NAME
       mkdir - make directories

SYNOPSIS
       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 ~]# ll
total 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 EOF
drwxr-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 ~]# ll
total 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.txt
drwxr-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 EOF
drwxr-xr-x  2 root root  4096 Jun  7 18:04 html
drwxr-xr-x  2 root root  4096 Jun  7 18:05 images
drwxr-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 ~]# ll
total 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.txt
drwxr-xr-x  2 root root  4096 Jun  7 18:05 common
drwxr-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 EOF
drwxr-xr-x  2 root root  4096 Jun  7 18:04 html
drwxr-xr-x  2 root root  4096 Jun  7 18:05 images
drwxr-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
drwxr-xr-x  2 root root  4096 Jun  7 18:05 js
drwxr-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]# ll
total 4
drwxr-xr-x 3 root root 4096 Jun  7 18:13 static
[root@guofeng web]# cd static/
[root@guofeng static]# ll
total 4
drwxr-xr-x 3 root root 4096 Jun  7 18:13 html
[root@guofeng static]# cd html
[root@guofeng html]# ll
total 4
drwxr-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/css
mkdir: 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 ~]# ll
total 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.txt
drwxr-xr-x  2 root root  4096 Jun  7 18:05 common
drwxr-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 EOF
drwxr-xr-x  3 root root  4096 Jun  7 18:18 htm
drwxr-xr-x  2 root root  4096 Jun  7 18:05 images
drwxr-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
drwxr-xr-x  2 root root  4096 Jun  7 18:05 js
drwxr-xr-x  2 root root  4096 Jun  7 18:05 plugin
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test
[root@guofeng ~]# 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值