mkdir a command to create a directory on a Linux system that requires the user to have write permission on the path where the directory was created, and that the newly created directory name cannot be a directory that already exists.
Mdkir-make Directories
Command format
mkdir [option] [directories]
Command description
Create the DIRECTORY (ies), if they does not already exist.
Create a directory (possibly multiple), if this directory does not exist to create, require users to create a directory with the Write permission to create a path, the directory name is case-sensitive
Command parameters
-m< Directory properties > or--mode< Directory properties > set directory permissions at the same time when the directory is established.
-P or--parents if the parent directory you want to create has not been created, the parent directory is created together
--HELP Display Help information
-V or--verbose displays detailed information when executed.
--version Display mkdir version information
Command instance
Example 1: Create an empty directory; Create a data directory under the/root directory
Command:
Mkdir/root/data
Command output:
[Email protected] ~]# mkdir/root/data[[email protected] ~]# ls-ld/root/datadrwxr-xr-x. 2 root root 4096 June 02:21/root/data[[email protected] ~]#
Example 2: Create a directory recursively; a command to create such a directory structure/root/data/a/b/c/d/e/f/g
Command:
Mkdir-p/root/data/a/b/c/d/e/f/g
Command output:
[[email protected] ~]# mkdir-p/root/data/a/b/c/d/e/f[[email protected] ~]# tree/root/data/root/data '--a '--b '--C '--d '--e '--F6 directories, 0 files[[email protected] ~]#
Example 3: Create a directory with directory permissions of 777; Create a/root/test directory with permissions of 777
Command:
Mkdir-m 777/root/test
Command output
[Email protected] ~]# mkdir-m 777/root/test[[email protected] ~]# ls-ld/root/testdrwxrwxrwx. 2 root root 4096 June 02:30/root/test[[email protected] ~]#
Example 4: Create a directory, display create information, create a/root/backup directory, you need to see the directory creation information
Command:
Mkdir-v/root/backup
Command output:
[Email protected] ~]# mkdir-v/root/backupmkdir:created directory '/root/backup ' [[email protected] ~]#
Example 5: A command to create a directory structure for a project;
Command:
Mkdir-vp/root/mkdirtest/{bin,sbin,lib,lib32,config/{conf.d,conf/{conf1,conf2}},info/{infomation/{},readme}}
Command output:
[[Email protected] ~]# mkdir -vp /root/mkdirtest/{bin,sbin,lib,lib32,config/{conf.d, conf/{conf1,conf2}},info/{infomation,readme}} mkdir: created directory '/root/ Mkdirtest ' mkdir: created directory '/root/mkdirtest/bin ' mkdir: created directory '/root/mkdirtest/sbin ' mkdir: created directory '/root/mkdirtest/lib ' mkdir: created directory '/root/mkdirtest/lib32 ' mkdir: created directory '/root/mkdirtest/config ' mkdir: created directory '/ROOT/MKDIRTEST/CONFIG/CONF.D ' mkdir: created directory '/root/mkdirtest/config/conf ' mkdir: created directory '/root/mkdirtest/config/conf/conf1 ' mkdir: created directory '/root/mkdirtest/config/conf/conf2 ' mkdir: created directory '/root/mkdirtest/info ' mkdir: created directory '/root/mkdirtest/info/infomation ' mkdir: created directory '/root/mkdirtest/info/readme ' [[email protected] ~]# tree /root/mkdirtest/root/ mkdirtest|-- bin|-- config| |-- conf| | |-- conf1| | '-- conf2| '-- conf.d|-- info | |-- infomation| '-- readme|-- lib|-- lib32 '-- sbin12 directories, 0 files[[email protected] ~]#
One Linux command per day-mkdir