Application of mkdir command in Linux

  
                

The mkdir command is mainly used to create folders in the Linux operating system, and the created folders cannot be renamed. The following small series will introduce you to the usage of the mkdir command in Linux, so that you can understand.

1. Command format:

mkdir [options] directory. . .

2. Command function:

The mkdir command enables you to create a folder or directory named DirName (specified file name) in the specified location. The user who wants to create a folder or directory must have write access to the parent folder of the folder being created. Moreover, the created folder (directory) cannot be the same as the file name in the parent directory (that is, the parent folder), that is, the same directory cannot have the same name (case sensitive).

3. Command parameters:

-m, --mode= mode, set permissions "mode" (similar to chmod) instead of rwxrwxrwx minus umask

-p, --parents can be a path name. At this point, if some directories in the path do not exist yet, with this option, the system will automatically create those directories that do not exist yet, that is, you can create multiple directories at a time;

-v, -- Verbose displays information every time you create a new directory

--help Display this help and exit

--version to output version information and exit

4. Command example:

Instance 1: Create an empty directory

Command:

mkdir test1

Output:

[root@localhost Soft]# cd test

[root@localhost test]# mkdir test1

[root@localhost test]# ll

Total 4drwxr-xr-x 2 root root 4096 10-25 17:42 test1

[root@localhost test]#

Instance 2: Recursively create multiple directories

Command:

mkdir - p test2/test22

Output:

[root@localhost test]# mkdir -p test2/test22

[root@localhost test]# ll

Total 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

Total 4drwxr-xr-x 2 root root 4096 10-25 17:44 test22

[ Root@localhost test2]#
Previous 12 Total 2

Copyright © Windows knowledge All Rights Reserved