What is the usage of the rmdir command in Linux?
The rmdir command in Linux is used to delete empty directories. Here is how to use the rmdir command:
remove [options] directory_name
Common options include:
- Delete the specified directory and all of its empty parent directories recursively.
- Display the names of the deleted directories.
- – Ignore errors for non-empty directories.
Example Usage:
- Remove an empty directory: rmdir dirname
For example: rmdir testdir - Remove a directory and all of its empty parent directories recursively using the command: rmdir -p dirname
For example: rmdir -p testdir/subdir - Display the deleted directory name: rmdir -v dirname
For example: rmdir -v testdir
Please note that the rmdir command can only delete empty directories. If there are files or other directories within the directory, you will need to use the rm command to delete non-empty directories.