Creating and deleting Catalogs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.