Get the App
SLTechnology News&Howtos  ›  Servers  › 

The usage of rmdir command in linux

Shulou Source: shulou.com Published: 2022-06-01 12:16:57 09月28日 Update

This article mainly explains "the usage of rmdir command in linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the usage of the rmdir command in linux.

1. Command format:

Rmdir [options]... Catalogue.

2. Command function:

This command deletes one or more subdirectory entries from a directory and must have write access to the parent directory when deleting a directory.

3. Command parameters:

-p the directory dirname is deleted recursively, and is also deleted when the parent directory is empty after the subdirectory is deleted. If the entire path is deleted or part of the path is retained for some reason, the system displays the corresponding information on the standard output.

-v,-- verbose shows the instruction execution process

4. Command example:

Example 1: rmdir cannot delete non-empty directories

Command:

Rmdir doc

Output:

[root@localhost scf] # tree

.

|-- bin

|-- doc

| |-- info |

| | `--product |

|-- lib

|-- logs

| |-- info |

| | `--product |

`--service

`--deploy

|-- info

`--product

12 directories, 0 files

[root@localhost scf] # rmdir doc

Rmdir: doc: directory is 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

10 directories, 0 files

Description:

The rmdir directory name command cannot delete a non-empty directory directly

Instance 2:rmdir-p if the subdirectory is deleted so that it is also empty, it will be deleted by the way

Command:

Rmdir-p logs

Output:

[root@localhost scf] # tree

.

|-- bin

|-- doc

|-- lib

|-- logs

| | `--product |

`--service

`--deploy

|-- info

`--product

10 directories, 0 files

[root@localhost scf] # rmdir-p logs

Rmdir: logs: directory is 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

At this point, I believe you have a deeper understanding of "the use of the rmdir command in linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Command directory subdirectory subdirectory instance empty directory output content path learning practical deeper information interest function reason parameter multiple practical practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB vpn Microsoft NVidia