The full text of the most detailed series -mkdir command Linux commands

Linux mkdir command to create the directory specified name, requires the user to create a directory with write permission in the current directory, and specify the directory name can not be the current directory has a directory.

  1. Format:

    mkdir [options] directory ...

  2. Function:

    It can be implemented to create DirName (specified file name) named folder or directory at the location specified by the mkdir command. User To create a folder or directory must have write permission on the parent folder created folders. In addition, files created folder (directory) can not be the parent directory (ie the parent folder) in the file name of the same name, that is, under the same directory can not have the same name (case-sensitive).

  3. Command parameters:

      -m, --mode=模式,设定权限<模式> (类似 chmod),而不是 rwxrwxrwx 减 umask
      -p, --parents  可以是一个路径名称。此时若路径中的某些目录尚不存在,加上此选项后,系统将自动建立好那些尚不存在的目录,即一次可以建立多个目录; 
      -v, --verbose  每次创建新目录都显示信息
      --help   显示此帮助信息并退出
      --version  输出版本信息并退出
  4. Command examples:

Example 1: Create an empty directory

command:

mkdir test1

Output:

[root@localhost soft]# cd test
[root@localhost test]# mkdir test1
[root@localhost test]# ll
总计 4drwxr-xr-x 2 root root 4096 10-25 17:42 test1
[root@localhost test]#

Example 2: Create multiple directories recursively
command:

mkdir -p test2/test22

Output:

[root@localhost test]# mkdir -p test2/test22
[root@localhost test]# ll
总计 8drwxr-xr-x 2 root root 4096 10-25 17:42 test1
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
[root@localhost test]# cd test2/
[root@localhost test2]# ll
总计 4drwxr-xr-x 2 root root 4096 10-25 17:44 test22
[root@localhost test2]#

Example 3: Create a directory permissions to 777
commands:

mkdir -m 777 test3

Output:

[root@localhost test]# mkdir -m 777 test3
[root@localhost test]# ll
总计 12drwxr-xr-x 2 root root 4096 10-25 17:42 test1
drwxr-xr-x 3 root root 4096 10-25 17:44 test2
drwxrwxrwx 2 root root 4096 10-25 17:46 test3
[root@localhost test]#

Description:
Test3 permissions for rwxrwxrwx

Example 4: Create a new directory will display information
command:

mkdir -v test4

Output:

[root@localhost test]# mkdir -v test4
mkdir: 已创建目录 “test4”
[root@localhost test]# mkdir -vp test5/test5-1
mkdir: 已创建目录 “test5”
mkdir: 已创建目录 “test5/test5-1”
[root@localhost test]#

Examples of five: a command to create a directory structure for the project
reference: http: //www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.html
command:

mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}
输出:
[root@localhost test]# mkdir -vp scf/{lib/,bin/,doc/{info,product},logs/{info,product},service/deploy/{info,product}}
mkdir: 已创建目录 “scf”
mkdir: 已创建目录 “scf/lib”
mkdir: 已创建目录 “scf/bin”
mkdir: 已创建目录 “scf/doc”
mkdir: 已创建目录 “scf/doc/info”
mkdir: 已创建目录 “scf/doc/product”
mkdir: 已创建目录 “scf/logs”
mkdir: 已创建目录 “scf/logs/info”
mkdir: 已创建目录 “scf/logs/product”
mkdir: 已创建目录 “scf/service”
mkdir: 已创建目录 “scf/service/deploy”
mkdir: 已创建目录 “scf/service/deploy/info”
mkdir: 已创建目录 “scf/service/deploy/product”
[root@localhost test]# tree scf/
scf/
|-- bin
|-- doc
|   |-- info
|   `-- product
|-- lib
|-- logs
|   |-- info
|   `-- product
`-- service
      `-- deploy
        |-- info
         `-- product
12 directories, 0 files
[root@localhost test]#

Guess you like

Origin www.cnblogs.com/passzhang/p/12130160.html