Files & folders

Linux rm command

Remove files. This does not normally move them to a recoverable trash folder.

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

rm [OPTION]... FILE...

Examples

Ask before deleting a file; -- ends option parsing.

rm -i -- old-draft.txt

Ask once before removing multiple matching files.

rm -I -- *.tmp

Parameters, options and clauses

Option / clauseDescription
-i, --interactive=alwaysPrompt before every removal.
-IPrompt once before removing many files or recursively.
-f, --forceIgnore nonexistent files and never prompt.
-r, -R, --recursiveRemove directories and their contents recursively.
-d, --dirRemove empty directories.
-v, --verbosePrint each removed item.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory