rm command
Delete files and directories.
- Files & directories
- Package coreutils
- 7 options · 8 examples
Syntax
rm [options] file…Provided by the coreutils package. Run man rm for the full manual.
Common options
| Option | What it does |
|---|---|
-r | Remove directories and their contents |
-f | Force: no prompts, ignore missing files |
-i | Ask before every removal |
-I | Ask once before removing more than 3 files |
-v | Print each file removed |
-d | Remove empty directories |
--preserve-root | Refuse to remove / (default) |
Examples
Delete a file
rm file.txtDelete several files
rm a.txt b.txtDelete all .log files here
rm *.logDelete a directory and everything in it
rm -r old-project/Delete without prompts
rm -rf build/Ask before each file
rm -i *.confDelete a file whose name starts with a dash
rm -- -file.txtToo many files for one command line
find . -name "*.tmp" -delete
No example matches. Check the options table or search the guides.
Tips
- There is no recycle bin: check paths before
rm -rf. - Run
lswith the same pattern first to see what will be deleted.
rm guides
- (Resolved) – /bin/rm: Argument list too long Linux Commands · Updated Apr 2025
