rm Remove files and directories
Deletes files, and with -r whole folders. There is no trash and no undo: removed files are gone. Check what you are about to delete before you press Enter.
Synopsis
rm [-f | -i] [-dIRrv] FILE...
Common options
| Option or form | What it does |
|---|---|
-r, -R | Remove folders and everything inside them. Needed for non-empty folders |
-d | Also remove empty folders, without needing -r |
-i | Interactive: ask before each removal |
-I | Ask once if more than three files, or a folder tree, would be removed |
-f | Force: no prompts, and no error if a file does not exist |
-v | Verbose: print each file as it is removed |
Examples
touch old.txt && rm old.txt
rm -i report.pdf draft.docx
touch a.tmp b.tmp && rm -v a.tmp b.tmp
mkdir scratch && rm -d scratch
rm -r docs/old
ls /var/log/app/*.log && rm -i /var/log/app/*.log
Notes
- Warning: rm deletes permanently. It does not use the Trash or Recycle Bin, and recovery is rarely possible. Run ls with the same pattern first to see what will match.
- Warning: rm -rf deletes a whole tree without asking. A stray space or a variable that turns out empty, as in rm -rf $DIR/, can remove far more than you meant. Quote variables and double-check paths.
- macOS rm refuses to remove /, . and .. but it will happily remove your home folder or a project folder if you tell it to.
- A name that starts with a dash is read as an option. Use rm -- -file or rm ./-file to delete it.
- -f hides errors for missing files. That is useful in scripts, but it can also hide typos, since rm -f with a wrong name reports success.
See also
Last reviewed 2026-10-07.