Linux first week study notes (15)

Source: Internet
Author: User
Tags create directory

Linux first week study notes (15)


2.8. Creating and deleting catalogs

mkdir Command (make directory shorthand ) : used to create a directory

mkdir–p command: Cascading create multiple directories

mkdir – PV command: Visualize cascading create multiple directories

rmdir Command ( Remove Directory abbreviated): used to delete empty directories, only to delete directories, not to delete files. (Must be empty in the directory to delete)

rmdir-p commands: cascading Create multiple directories (must be empty)

Touch command: used to create a new empty file

-----------------------------------------------------------------------------------------

mkdir To Create a directory:

[Email protected] ~]# Mkdir/tmp/daizhihong

[Email protected] ~]# ls/tmp/daizhohng/

[Email protected] ~]# ls-ld/tmp/daizhihong/

drwxr-xr-x 2 root root 6 1 Month 23:31/tmp/daizhihong/

-------------------------------------------------------------------------------------------

[Email protected] ~]# mkdir/tmp/daizhihong/01/02/03/04

mkdir: Unable to create directory "/tmp/daizhihong/01/02/03/04": there is no file or directory ( mkdir multiple cascading directories cannot be created when the command is used alone

mkdir P Create multiple cascading catalogs (add Parameters P Create multiple cascading directories):

[Email protected] ~]# mkdir-p/tmp/daizhihong/01/02/03/04

[Email protected] ~]# ls-l/tmp/daizhihong/

Total Dosage 0

drwxr-xr-x 3 root root 1 Month 23:46

[Email protected] ~]# ls-l/tmp/daizhihong/01

Total Dosage 0

drwxr-xr-x 3 root root 1 Month 23:46

[Email protected] ~]# ls-l/tmp/daizhihong/01/02

Total Dosage 0

drwxr-xr-x 3 root root 1 Month 23:46

[Email protected] ~]# ls-l/tmp/daizhihong/01/02/03

Total Dosage 0

drwxr-xr-x 2 root root 6 1 Month 23:46, Geneva

mkdir PV Create multiple cascading catalogs visually (add parameters V is visualized):

[Email protected] ~]# mkdir-pv/tmp/daizhihong1/01/02/03/04

mkdir: The directory has been created "/tmp/daizhihong1"

mkdir: The directory has been created "/tmp/daizhihong1/01"

mkdir: The directory has been created "/tmp/daizhihong1/01/02"

mkdir: The directory has been created "/tmp/daizhihong1/01/02/03"

mkdir: The directory has been created "/tmp/daizhihong1/01/02/03/04"

[Email protected] ~]#

----------------------------------------------------------------------------------------------

rmdir To Delete a directory:

[Email protected] ~]# rmdir/tmp/daizhihong/01/02/03/04

[Email protected] ~]#

[Email protected] ~]# ls-l/tmp/daizhihong/01/02/03/04

ls: Cannot access /tmp/daizhihong/01/02/03/04: no file or directory

Delete directory /04/ Success

-----------------------------------------------------------------------------------------------

rmdir To Delete multiple directories:

[Email protected] ~]# rmdir/tmp/daizhihong/01/02/03

rmdir: Delete "/tmp/daizhihong/01" failed : Directory non-empty ( rmdir Delete Directory can only delete a directory, and multiple directories can not be deleted)

---------------------------------------------------------------------------------------------

[Email protected] ~]# Touch/tmp/daizhihong/01/02/11.txt

[Email protected] ~]# tree/tmp/daizhihong/01/02/

/tmp/daizhihong/01/02/

├── Geneva

│ └── 11.txt

└── 11.txt

1 directory, 2 files

[Email protected] ~]# rmdir/tmp/daizhihong/01/02/

rmdir: Delete "/tmp/daizhihong/01/02/" failed : Directory non-empty

rmdir When you delete a directory, there are files that cannot be deleted.

-----------------------------------------------------------------------------------------------

rmdir-p To Delete multiple directories:

[Email protected] ~]# rmdir-p/tmp/daizhihong/01/02/03

rmdir: Delete "/tmp/daizhihong/01/02/03" failed : Directory non-empty

[Email protected] ~]# tree/tmp/daizhihong/01/02/03

/tmp/daizhihong/01/02/03

└── 11.txt

0 directories, 1 file

Use rmdir-p The command is capable of deleting multiple directories, prompting the deletion to fail because /tmp/daizhihong/ There are files in the directory so you can't delete them. /daizhihong/ Catalogue ,

rmdir-p command is usually not used, because easy to confuse easy to delete the wrong, as long as the empty directory will be deleted directly .


Linux first week study notes (15)

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.