Command: mkdir; rmdir; tree
Mkdir ---- make directory
Syntax: mkdir [-MP] [directory name]
If the mkdir directory is directly followed by no option, a subdirectory will be created at the upper level of the last directory. If the upper level does not exist, a series of directories cannot be created.
To create a series of directories, use mkdir-P [directory name]. Mkdir-V [directory name] indicates creating process visualization.
[[Email protected] ~] # Mkdir234
[[Email protected] ~] # Ls-D/root/234
/Root/234
[[Email protected] ~] # Mkdir/tmp/1/2/3
Mkdir: Unable to create directory "/tmp/1/2/3": No file or directory
[[Email protected] ~] # Man mkdir
[[Email protected] ~] # Mkdir-PV/tmp/1/2/3
Mkdir: the directory "/tmp/1" has been created"
Mkdir: the directory "/tmp/1/2" has been created"
Mkdir: the directory "/tmp/1/2/3" has been created"
Rmdir is used to delete empty directories. One or more directories can be followed by spaces.
Similar to mkdir, it has the-P option and can also cascade to delete a large number of directories. However, it is not easy to use when there are other directories or files in the cascading directory.
Tree can display the directory tree
[[Email protected] ~] # Rmdir/tmp/1/2/3
[[Email protected] ~] # Tree/tmp
/Tmp
── 1
│ ── 2 2
── Yum. Log
2 directories, 1 file
[[Email protected] ~] # Mkdir-P/tmp/1/2/3/4
[[Email protected] ~] # Tree/tmp
/Tmp
── 1
│ ── 2 2
│ ── 3
│ ── 4 4
── Yum. Log
4 directories, 1 file
[[Email protected] ~] # Rmdir/tmp/1
Rmdir: failed to delete "/tmp/1": the directory is not empty
[[Email protected] ~] # Rmdir/tmp/1/2/3/4
[[Email protected] ~] # Tree/tmp
/Tmp
── 1
│ ── 2 2
│ ── 3
── Yum. Log
3 directories, 1 file
[[Email protected] ~] # Rmdir-PV/tmp/1/2/3
Rmdir: deleting directory "/tmp/1/2/3"
Rmdir: deleting directory "/tmp/1/2"
Rmdir: deleting directory "/tmp/1"
Rmdir: deleting directory "/tmp"
Rmdir: failed to delete directory "/tmp": directory is not empty
[[Email protected] ~] # Cd/tmp
[[Email protected] TMP] # mkdir-P 1/2/3
[[Email protected] TMP] # rmdir-PV 1/2/3
Rmdir: deleting directory "1/2/3"
Rmdir: the directory "1/2" is being deleted"
Rmdir: deleting directory "1"
[[Email protected] TMP] # mkdir-P 1/22/1
[[Email protected] TMP] # mkdir-P 1/2/3
[[Email protected] TMP] # rmdir-PV 1/2/3
Rmdir: deleting directory "1/2/3"
Rmdir: the directory "1/2" is being deleted"
Rmdir: deleting directory "1"
Rmdir: failed to delete directory "1": directory is not empty
[[Email protected] TMP] # rmdir-P 1/22/1
[[Email protected] TMP] # tree/tmp
/Tmp
── Yum. Log
0 directories, 1 file
Create and delete directories