mkdir命令
1.命令功能
mkdir make directories
如果目录不存在,则创建目录。
Create the DIRECTORY(ies), if they do not already exist.
2.命令格式
[root@localhost ~]# mkdir [选项]... 目录...
3.参考事例
- 在工作目录下,建立一个名为 tmp的子目录:
[root@localhost ~]# mkdir tmp
- 在目录/home/tmp下建立子目录yejx,并且设置文件属主有读、写和执行权限,其他人无权访问
[root@localhost ~]# mkdir -m 700 /home/tmp/yejx
- 同时创建子目录yejx,yejx1
[root@localhost ~]# mkdir yejx yejx2
- 递归创建目录:
[root@localhost ~]# mkdir -p yejx/dir
4.参数详解
选项 | 释义 | 功能描述 |
---|---|---|
-m | 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将每个创建的目录的SELinux安全上下文设置为默认类型 |