15.08.2023
22:00
The rmdir command in Linux is used to delete empty directories (folders). It only deletes directories that do not contain any subdirectories or files. If a directory is not empty, rmdir will display an error message and will not delete it.
Examples of how to use the command
Using the rmdir command:
rmdir <director_name>
Example:
rmdir directory_name
Some options for the rmdir command are:
-p: allows you to delete a directory and its parent directories if they remain empty after deletion. --ignore-fail-on-non-empty: allows you to ignore an error message if the directory is not empty. --verbose: displays detailed information about the directory deletion process.Note: Be careful when using the rmdir command because it does not perform file or directory recovery after deletion
How to install
There is no need to install the rmdir command, as it is built-in to most Linux distributions.
If for some reason the rmdir command is missing or unavailable on your system, you can install it as follows:
- Make sure you have superuser (root) or administrator privileges.
- Open a terminal or console and run the following command depending on your distribution.
- For Debian-based distributions (Ubuntu, Linux Mint, etc.):
sudo apt-get install coreutils - For Red Hat-based distributions (Fedora, CentOS, etc.):
orsudo dnf install coreutils
sudo yum install coreutils - For Arch Linux-based distributions (Manjaro, etc.):
sudo pacman -S coreutils - After running the install command, the rmdir command should be available and ready to use.
Note that the rmdir command may also be available in other packages, so you can use your distribution's package manager to find and install a package containing this command.
15% discount on new VPS
Hurry up to order a server in any location
Other articles
15.08.2023
23 766
Knowledge base / Commands
15.08.2023
36 867
Knowledge base / Commands
15.08.2023
71 163
Knowledge base / Commands