Linux Commands | File Management | rmdir Delete Directories

rmdir

rmdir is a command used to delete empty directories.

rmdir is short for “remove directory”.

rmdir Syntax

rmdir (options) [directory name to delete]

rmdir Options

Option Description
-p Also deletes parent directories.

rmdir Examples

Delete an empty directory named aaa

rmdir aaa

Delete all empty directories a, b, and c under /a/b/c

rmdir -p /a/b/c

If files exist in any directory, that directory and its parent directories are not deleted.