LOGBOOK

HELP

Quiz Entry - updated: 2026.07.30

What is the difference between rm, rmdir, and rm -r?

rm deletes files, rmdir deletes only empty directories, and rm -r deletes a directory together with everything inside it. They differ by what they'll touch and how much they'll take with them.

The interesting one is why rmdir exists at all when rm -r can delete any directory. The answer is safety through refusal: rmdir deliberately fails if the directory still has anything in it.

Command Deletes Refuses when…
rm file One or more files
rmdir dir An empty directory the directory isn't empty
rm -r dir A directory and all contents (it doesn't refuse — that's the danger)
rm doc.txt              # one file
rm a.txt b.txt c.txt    # several files
rmdir empty_folder      # only works if it's truly empty
rm -r project_folder    # folder + everything under it

So rmdir acts as a guardrail. When you think a folder is empty and want to clean it up, rmdir confirms your assumption — if it errors out, you've just learned there was data you'd have destroyed with rm -r. It forces you to consciously decide to delete non-empty directories.

Warning: rm -r has no such brake. rm -rf / would try to erase the entire system; modern rm blocks that exact path with --preserve-root by default, but it will not save you from rm -rf ~/important_project. The habit that protects you is reading the path before you hit Enter, not relying on safeguards.

From Quiz: LIOS / Files and Directories | Updated: Jul 30, 2026