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
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
rm -r old-notes
rm prints nothing when it works.
Step 2: Check It’s Gone
ls
notes
Only notes is left.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Leaving out -r: rm old-notes | rm: old-notes: is a directory | Add -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
- rm (opens in a new tab) (POSIX standard)
macOS is a trademark of Apple Inc.
0 comments