Create and delete directories

Source: Internet
Author: User

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

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.