Linux命令--mkdir

1.命令介绍

linux mkdir 命令用来创建指定的名称的目录,要求创建目录的用户在当前目录中具有写权限,并且指定的目录名不能是当前目录中已有的目录。

2.命令用途

创建文件夹

3.命令使用说明

[root@moban ~]# mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
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

4.命令常用参数说明

参数选项 参数说明
-m 在创建文件夹时,自己设定文件夹权限
-p 若创建子目录不存在,可递归创建
-v 显示创建目录的信息

5.命令示例

5.1 不带参数

[root@moban ~]# mkdir /test1

[root@moban ~]# ls -ld /test1
drwxr-xr-x 2 root root 4096 Sep 25 10:50 /test1

5.2 -p参数

[root@moban ~]# mkdir /test2/abc
mkdir: cannot create directory `/test2/abc': No such file or directory
[root@moban ~]# mkdir -p /test2/abc
[root@moban ~]# ll -ld /test2/abc
drwxr-xr-x 2 root root 4096 Sep 25 10:51 /test2/abc

5.3 -m参数

[root@moban ~]# mkdir /aaa
[root@moban ~]# ls -ld /aaa
drwxr-xr-x 2 root root 4096 Sep 25 10:52 /aaa

[root@moban ~]# mkdir -m 777 bbb
[root@moban ~]# ls -ld bbb
drwxrwxrwx 2 root root 4096 Sep 25 10:53 bbb

5.4 -v参数

[root@moban ~]# mkdir -v ccc
mkdir: created directory `ccc'

原文地址:https://www.cnblogs.com/ladeng/p/4837529.html