mkdir命令是用来创建目录
命令格式
mkdir [选项] 目录名
mkdir [OPTION]… DIRECTORY…
选项:
-m:指定新建目录的权限;
-p:如果指定的路径中的目录不存在,则先创建它们;
-v:显示详细的处理信息;
-Z:设置安全上下文;
–help:显示帮助信息。
例子:
例1,一次创建多个目录:
study@DESKTOP:~$ mkdir m1 m2
study@DESKTOP:~$ ls
m1 m2
例2,当创建多级目录,上级目录不存在时,系统提示:
study@DESKTOP:~$ mkdir a/b/c
mkdir: cannot create directory ‘a/b/c’: No such file or directory
解决:使用-p参数,自动创建上级目录
study@DESKTOP:~$ mkdir -p a/b/c
study@DESKTOP:~$ ls -R a/
a/:
b
a/b:
c
a/b/c:
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