Site icon JD Bots

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

Syntax

rm -r folder

See rm 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

Terminal

rm -r old-notes

rm prints nothing when it works.

Step 2: Check It’s Gone

Terminal

ls

Output

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.

Exit mobile version