Linux
linuxlinux-commandsReferenceBeginner
Remove Files & Directories (rm)
Remove files and directories in Linux, with safety warnings for recursive and forced deletion (rm -rf).
Verified: 2026-09-30
Tested on:linux Ubuntu 24.04 / Debian 12
Platforms:
linuxmacos
#linux#rm#deletion#files#cli
Command
rm -rf /path/to/target
Short Description
rm (Remove) deletes files or directories from the filesystem.
[!CAUTION] Deletions with
rmare permanent and non-recoverable. There is no trash bin. Never runrm -rf /or commands with unexpanded variables (e.g.rm -rf $DIR/where$DIRis empty, evaluating torm -rf /).
Examples
1. Remove a Single File
rm temp_file.log2. Remove Multiple Files with Wildcard
rm *.tmp3. Remove a Directory Recursively (-r)
rm -r build/4. Force Remove Recursively Without Confirmation Prompts (-rf)
rm -rf node_modules/ .next/5. Interactive Confirmation Mode (-i)
rm -i important_document.pdf