Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use the rmdir command of linux to delete an empty directory

Shulou Source: shulou.com Published: 2022-06-02 19:50:35 09月13日 Update

Today, the editor shares with you how to use linux's rmdir command to delete empty directories. I believe many people don't know much about it. In order to make you understand better, I summarized the following contents and looked down together. I'm sure you'll get something.

The function of the rmdir command is to delete the empty directory, the full name in English is "remove directory".

Note: the rmdir command can only delete empty directories. When you want to delete a non-empty directory, use the rm command with the "- R" option.

The "- p" parameter of the rmdir command can recursively delete a specified multi-level directory, but requires that each directory must also be empty.

Syntax format: rmdir [parameters] [directory name]

Common parameters:

Reference example

Delete an empty directory:

[root@linuxcool ~] # rmdir dir

Recursively delete the specified directory tree:

[root@linuxcool] # rmdir-p dir/dir_1/dir_2

Displays the detailed execution process of the instruction:

[root@linuxcool] # rmdir-v dir

Rmdir: deleting directory 'dir' [root@linuxcool ~] # rmdir-p-v dir/dir_1/dir_2

Rmdir: deleting directory 'dir/dir_1/dir_2

Rmdir: deleting directory 'dir/dir_1'

Rmdir: deleting directory 'dir_2'

Displays the version information of the command:

[root@linuxcool] # rmdir-- versionrmdir (GNU coreutils) 8.30Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+:GNU General Public license version 3 or later https://gnu.org/licenses/gpl.html. This software is free: you are free to modify and redistribute it. There is no other guarantee within the scope of the law. On how to use linux's rmdir command to delete the empty directory is shared here, I hope that the above content can have a certain reference value, you can learn to apply. If you like this article, you might as well share it for more people to see.

Tags: Directory command empty directory active parameter free content version license software recursion reference application of knowledge value function information full name name instance commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi vpn Docker Huawei Linux