Linux命令大全: mkdir命令 - 创建目录

1. 详解

mkdir命令是“make directories”的缩写,用来创建目录。

注意:
默认状态下,如果要创建的目录已经存在,则提示已存在,而不会继续创建目录。
所以在创建目录时,应保证新建的目录与它所在目录下的文件没有重名。
mkdir命令还可以同时创建多个目录,是不是很强大呢?

语法格式 : mkdir [参数] [目录]

常用参数:

参数说明
-p递归创建多级目录
-m建立目录的同时设置目录的权限
-z设置安全上下文
-v显示目录的创建过程

2. 参考实例

  1. 在工作目录下,建立一个名为 dir 的子目录:
> mkdir dir
  1. 在目录/usr/linuxcool下建立子目录dir,并且设置文件属主有读、写和执行权限,其他人无权访问
> mkdir -m 700 /usr/dreamhai/dir
  1. 同时创建子目录dir1,dir2,dir3:
> mkdir dir1 dir2 dir3
  1. 递归创建目录:
> mkdir -p draemhai/dir

3. 系统文档(mkdir man)

MKDIR(1)                                       User Commands                                      MKDIR(1)

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     set SELinux security context of each created directory to the default type

       --context[=CTX]
              like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX

       --help display this help and exit

       --version
              output version information and exit

AUTHOR
       Written by David MacKenzie.

REPORTING BUGS
       GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
       Report mkdir translation bugs to <http://translationproject.org/team/>

COPYRIGHT
       Copyright  ©  2016  Free  Software  Foundation,  Inc.   License  GPLv3+: GNU GPL version 3 or later
       <http://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it.  There is NO  WARRANTY,  to  the
       extent permitted by law.

SEE ALSO
       mkdir(2)

       Full documentation at: <http://www.gnu.org/software/coreutils/mkdir>
       or available locally via: info '(coreutils) mkdir invocation'

GNU coreutils 8.25                             February 2016                                      MKDIR(1)

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值