rmdir

Remove empty directories

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

Deletes directories only if they are empty — a safer alternative to rm -r when you expect nothing to be inside.

Common flags
FlagMeaning
-pRemove parent directories too if they become empty
--ignore-fail-on-non-empty --ignore-fail-on-non-emptyDo not complain about non-empty directories
Examples
rmdir buildRemove an empty directory · explain & risk-check →
rmdir -p a/b/cRemove c, then b and a if empty · explain & risk-check →
Pro tip

Prefer rmdir over rm -r when the directory should be empty — it fails loudly if it is not.

Related
rm mkdir find
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man rmdir for your version. Test destructive commands on a non-production system first.