Linux rmdir command

Updated: 06/16/2017 by Computer Hope

About rmdir

The rmdir command removes a directory from your filesystem.


The rmdir utility removes the directory entry specified by each directory argument if the directory contains no files. If the directory is not empty, rmdir will not remove it.

Arguments are processed in the order given. To remove both a parent directory and a subdirectory of that parent, the subdirectory must be specified first so the parent directory is empty when rmdir tries to remove it.

rmdir syntax

rmdir [-p] directory ...


--ignore-fail-on-non-empty ignore any failure which occurs solely because a directory is non-empty.
-p Each directory argument is treated as a pathname of which all components will be removed, if they are empty, starting with the last component. (See rm for fully non-discriminant recursive removal.)
-v, --verbose Display verbose information for every directory processed.
--help Display a help message, and exit.
--version Output version information, and exit.

rmdir examples

rmdir mydir

Removes the directory mydir.

mkdir — Create a directory.
rm — Delete files.