rm removes files — immediately, permanently, and without asking. There is no trash can on a typical Linux system, which makes rm the most powerful command in this series and the one that deserves the most respect.

Everyday removal #

Remove files and directories
$ rm notes.txt
$ rm old/*.log
$ rm -r old-builds/

Plain rm handles files. -r (recursive) is required for directories and their contents.

The flags #

FlagBehaviour
-rRecurse into directories
-fForce: ignore missing files, suppress prompts
-iPrompt before every removal
-IPrompt once before removing more than three files
-vPrint each file as it is removed

The two-step habit is the safest pattern: list what a glob matches, then remove it.

Look before you delete
$ ls old/*.log
$ rm old/*.log

When age matters #

rm does not care about recency, but find does — and pairing them is the classic cleanup:

Delete log files older than 30 days
$ find /var/log/myapp -name "*.log" -mtime +30 -delete

The -delete form is safer than piping into rm because find only acts on paths its tests matched. See find for the full tour.

Accidental deletion is a backup problem, not a shell problem: snapshots, git, or a nightly tar archive are what stand between a typo and data loss. Before removing, it helps to see exactly what is there with ls. More in the journal.