File and Folder Operations

rmdir

Removes empty directories.

rmdir deletes directories only when they are empty, making it safer than rm -r for cleanup.

Syntax
rmdir [options] directory...

Arguments explained

  • directory is an empty folder to remove.
  • -p can remove empty parent directories too.

Common examples

Remove an empty folder
rmdir empty-folder

Succeeds only if the folder has no contents.

Remove empty nested parents
rmdir -p a/b/c

Removes c, then b, then a if each becomes empty.

rmdir Command
FieldDetails
Commandrmdir
CategoryFile and Folder Operations
Primary useRemoves empty directories.
Syntaxrmdir [options] directory...