Delete files and folders with rm

Remove files and directory trees from the shell — with the guard rails you should always use.

LinuxdeleteFilesHigh risk
Run rm file.txt for one file, rm -ri folder/ to delete a folder interactively with a confirmation prompt.

01Command

Command
$ rm -i report-draft.txt && rm -ri old-build/

02What it does

rm unlinks files immediately — nothing goes to a trash can. -r is required for directories, -i asks before each deletion, and -I (capital) prompts once for three or more files, a good middle ground. Wildcards like rm *.tmp work, but the shell expands them before rm ever sees the list.

03Risk

RiskHigh risk
!Warning: This is the most dangerous command in daily use: rm -rf with a mistyped or unquoted variable (rm -rf $DIR/ — empty variable) has destroyed systems. There is no undo. Consider trash-cli, and always ls the glob pattern before rm-ing it.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • rm(1) — Linux manual page
    man7.org · community · 2026-09-17
    Evidence: rm removes files; -r deletes directories recursively, -i prompts before every removal, and deleted files are not moved to any trash.

Last verified: 2026-09-18 · Category: Files & Folders

06Related solutions