$rm
Remove files or directories from the filesystem.
rm [OPTIONS] FILE...Try `rm` Live in Interactive Sandbox
Zero-install client simulation with real-time feedback.
Overview & How rm Works
`rm` (Remove) deletes files and directories. Linux filesystems do not have a "Recycle Bin" or "Trash" for CLI commands—once a file is removed with `rm`, its data blocks are unlinked immediately. Combining `-r` (recursive) and `-f` (force) allows removing non-empty directory trees.
Common Flags & Command Options
| Flag / Option | Description |
|---|---|
| -r, -R | Remove directories and their contents recursively. |
| -f | Force removal without prompting for confirmation or reporting non-existent files. |
| -i | Prompt interactively before every file removal. |
| -v | Verbose mode explaining what is being deleted. |
Practical Real-World Examples
rm /home/user/notes.txt && ls -lDeletes notes.txt and verifies the directory listing.
rm -rf /tmp/test_dirForces recursive removal of the test directory without confirmation prompts.
Common Errors & Troubleshooting
Frequently Asked Questions
Can you recover files deleted with rm in Linux?
CLI deletion directly unlinks filesystem inodes. Without specialized forensic carving tools or backups, files deleted with `rm` cannot be easily recovered.
Related Linux Commands
Search for files and directories in a directory hierarchy based on name, type, size, or modification date.
Concatenate and print file contents directly to the terminal standard output.
Create new directories and folder hierarchies.
Copy files and directories to a destination path.
Move or rename files and directories.
Create empty files or update file access and modification timestamps.