One Linux command per day (6): rmdir command

Source: Internet
Author: User
Tags parent directory

Learn about Linux commands today: the RmDir command. RmDir is a commonly used command, the function of which is to delete an empty directory before a directory is deleted must be empty. (Note that the Rm–r dir command can be used instead of rmdir, but there is a lot of danger.) You must also have write access to the parent directory when you delete a directory.

1. Command format:

rmdir [Options] ... Directory...

2. Command function:

This command removes one or more subdirectory entries from a directory and must also have write access to the parent directory when a directory is deleted.

3. Command parameters:

- p recursively deletes the directory dirname, which is also deleted when its parent directory is empty after the subdirectory is deleted.

If the entire path is deleted or a partial path is reserved for some reason, the system displays the appropriate information on the standard output.

-v, --verbose display instruction execution process

4. Command instance:

Instance one: RmDir cannot delete a non-empty directory

Command:

RmDir Doc

Output:

[root@localhost scf]# tree

.

|-- bin

|-- Doc

| |-- Info

| '-- product

|-- Lib

|-- Logs

| |-- Info

| '-- product

'-- service

'-- deploy

|-- Info

'-- product

directories, 0 files

[root@localhost scf]# rmdir doc

RmDir: doc: directory not empty

[root@localhost scf]# rmdir doc/info

[root@localhost scf]# rmdir doc/product

[root@localhost scf]# tree

.

|-- bin

|-- Doc

|-- Lib

|-- Logs

| |-- Info

| '-- product

'-- service

'-- deploy

|-- Info

'-- product

Ten directories, 0 files

Description

RmDir Directory name command cannot delete a non-empty directory directly

Instance 2:rmdir-p when a subdirectory is deleted and makes it an empty directory, it is deleted by the way

Command:

RmDir -p logs

Output:

[root@localhost scf]# tree

.

|-- bin

|-- Doc

|-- Lib

|-- Logs

| '-- product

'-- service

'-- deploy

|-- Info

'-- product

Ten directories, 0 files

[root@localhost scf]# rmdir-p logs

RmDir: logs: directory not empty

[root@localhost scf]# tree

.

|-- bin

|-- Doc

|-- Lib

|-- Logs

| '-- product

'-- service

'-- deploy

|-- Info

'-- product

9 directories, 0 files

[root@localhost scf]# rmdir-p logs/product

[root@localhost scf]# tree

.

|-- bin

|-- Doc

|-- Lib

'-- service

'-- deploy

|-- Info

'-- product

7 directories, 0 files

One Linux command per day (6): rmdir command

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.