Skip to main content
0 reactions

How to Delete a Folder in the Terminal with rm -r

Card titled rm -r in the Terminal, labelled shell basics, with three ticked lines: rm -r old-notes, then ls, which shows only notes.

rm -r deletes a folder together with every file and folder inside it.

Warning: rm deletes for good. The folder doesn’t go to the Trash, so it can’t be put back from there. Check the name before you press Return.

Every command and output on this page is real, run in Terminal with zsh 5.9 on macOS 26.

Syntax

SyntaxBash
rm -r folder
  • rm: the command that deletes.
  • -r: also delete everything inside the folder. Without it, rm won’t delete a folder.
  • folder: the folder to delete.

See rm (opens in a new tab) in the POSIX standard.

The Example

Two folders, old-notes and notes. old-notes holds a file named draft.txt.

Step 1: Delete the Folder

TerminalBash
rm -r old-notes

rm prints nothing when it works.

Step 2: Check It’s Gone

TerminalBash
ls
OutputPlain text
notes

Only notes is left.

Common Mistakes

MistakeWhat happensDo this instead
Leaving out -r: rm old-notesrm: old-notes: is a directoryAdd -r

FAQ

Can I get the folder back?

Not from the Trash: rm doesn’t use it. Only a backup you made earlier can bring it back.

Conclusion

rm -r deletes a folder and everything in it, at once and for good, so check the name first.

Additional Resources

macOS is a trademark of Apple Inc.

0 comments