A tiny, focused command to delete only empty directories so you avoid accidental data loss. 26.04.2026 | reading time: 2 min Short and decisive: `rmdir` deletes directories only when they are empty, making it a safer alternative to recursive removal; learn how a few flags change its behavior and when to prefer other tools. Hands-on demo Create a small scenario and try these commands yourself: ```bash $ mkdir -p demo/project/src $ touch demo/project/src/main.c $ rmdir demo/project/src rmdir: failed to remove 'demo/project/src': Directory not empty $ rm demo/project/src/main.c $ rmdir -v demo/project/src demo/project rmdir: removing directory, 'demo/project/src' rmdir: removing directory, 'demo/project' ``` Options that actually help Use `-p` to remove directory and any now-empty parents in one go, and `-v` to get human-readable feedback; `--ignore-fail-on-non-empty` suppresses errors caused by non-empty directories; remember that `rmdir` only succeeds on truly empty directories and respects filesystem permissions. When to choose something else If a directory contains files or subdirectories, use `rm -r` or a careful `find -delete` pipeline instead; `rmdir` will refuse symlinks and non-empty directories, which is a safety feature not a limitation, and you must have write/search permission on the parent to remove an entry. Last step Mastering small, safe commands like `rmdir` reduces mistakes and builds confidence; take the next step and deepen your Linux skills with structured study, possibly aiming for CompTIA Linux+ or LPIC-1, and consider bitsandbytes.academy for intensive exam preparation. Join Bits & Bytes Academy First class LINUX exam preparation. filesystem utilities scripting troubleshooting