Online Linux Terminal Logo
OnlineLinuxTerminal
File OperationsCLI Reference

$rm

Remove files or directories from the filesystem.

Syntax DefinitionPOSIX standard
rm [OPTIONS] FILE...
Linux Community2.4k Online

Chat with real Linux users, learn new commands & get free cheat sheet PDFs.

Try `rm` Live in Interactive Sandbox

Zero-install client simulation with real-time feedback.

Open in Fullscreen Workspace↗
bash — terminal

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 / OptionDescription
-r, -RRemove directories and their contents recursively.
-fForce removal without prompting for confirmation or reporting non-existent files.
-iPrompt interactively before every file removal.
-vVerbose mode explaining what is being deleted.

Practical Real-World Examples

Example #1Remove a specific file
rm /home/user/notes.txt && ls -l

Deletes notes.txt and verifies the directory listing.

Example #2Recursively delete a directory and all files
rm -rf /tmp/test_dir

Forces recursive removal of the test directory without confirmation prompts.

Common Errors & Troubleshooting

rm: cannot remove ...: Is a directory
Cause: Attempted to remove a directory without the recursive `-r` flag.
Solution: Use `rm -r [directory]` or `rm -rf [directory]`.

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.