To Create a directory:
mkdir can be created as an absolute path, that is, starting from the root.
You can also write a path relative to the current directory.
of course directories can be viewed using PWD
we want to create a 111 directory under root
command: mkdir/root/111
we create a directory to specify either a relative path or an absolute path
If you create a series of directories MKDIR/TMP/1/2/3/4/5 this will cause an error.
first we want to go into the TMP directory under the 1 directory under the 2 directory under the 3 directory under the 4 directory down to create 5
cannot create 5 without the 2/3/4 directory
You can check the usage of this command for such a mistake .
use man to view help information
Man mkdir can use the keyboard up and down button to flip down
Here's a-m-p we used to be P is the English word parents (parents mean)
Here we can use it to implement if 2/3/4 does not exist it will automatically create the
MKDIR-PV (v is formatted meaning) TMP/1/2/3/4/5
This will automatically create a
To Delete a directory:
rmdir If you delete the 5 directory rmdir 5
You can also use the absolute path RMDIR/TMP/5
What if we delete the/TMP/1/2/3/4 string?
rmdir TMP/1/2/3/4 Actually there are 1 directories we can use the tree command to view the next TREE/TMP/1
If this tree doesn't exist, it needs to be installed with the Yum command .
Yum install-y Tree
If you are minimizing the installation of the tree This command is not present and needs to be installed with the Yum command
after installing the input TREE/TMP/1 can view the structure of his
there's a 4 directory under the directory, but I just deleted it.
Create a TMP/1/2/3/4/5
mkdir-p TMP/1/2/3/4/5
when using the command TREE/TMP/1 view
If you remove 12345 from 1, delete rmdir tmp/1 will prompt the directory non-empty we delete 4 is no problem
If you want to remove this list of directories, how to do it?
We can also use the man rmdir to see the same also has a-p parents-v visualization
Well, let's add it. If the TMP directory is not deleted under the direct rmdir-pv/tmp/1/2/3/4/directory, because the TMP directory is not empty
we need to get into the TMP directory cd/tmp/
RMDIR-PV 1/2/3/4
Summary:
Mkdir-p can be created as a string of Create-V can see his creation process rmdir is used to delete empty directories are non-empty directories cannot be deleted-P is we can even delete the parent directory, but the directory must be empty
we create a MKDIR-PV 1/22/1 directory
We're going to remove RMDIR-PV 1/2/3 He can't delete the 1 directory because there's a 22 directory under the 1 directory.
so-P only supports deleting a string of empty directories
Creating and deleting Catalogs