Linux – rmdir Command

The rmdir command stands for “remove directory.” It is used to delete empty directories from the file system. Unlike the rm command, which can delete files and directories regardless of their contents, rmdir only removes directories that are empty.

Initial Example

Using rmdir to remove an empty directory called OldFolder:

Tutorials dojo strip
UNIX

RMDIR Parameters

ParameterDescription
--ignore-fail-on-non-emptySkip errors when trying to remove directories that are not empty
-p, --parentsRemove a directory and its parent directories, e.g., rmdir -p a/b removes a/b and a
-v, --verboseDisplay a message for each directory that is being removed
--helpShow help information and exit
--versionDisplay version information and exit




Examples

1. Remove a Single Empty Directory

To remove an empty directory:

UNIX

2. Remove Multiple Empty Directories

To remove multiple empty directories at once, specify their names separated by spaces:

UNIX

3. Remove Nested Empty Directories

To remove a directory and its empty parent directories, use the -p option:

UNIX

Linux Playground

Tutorials dojo strip
Scroll to Top