rm
TLDR
Remove a file
SYNOPSIS
rm [-firvd] file...
DESCRIPTION
rm removes files and directories. By default, it does not remove directories; use -r to remove directories recursively.
Without -f, rm prompts for confirmation when removing write-protected files. With -i, it prompts for every file. The -I option provides a middle ground, prompting once for potentially dangerous operations.
To remove a file starting with a dash, use -- to end option processing: rm -- -filename or use a path: rm ./-filename.
The command unlinks files from the filesystem. Data may be recoverable until overwritten. For secure deletion, use shred.
PARAMETERS
-f, --force
Ignore nonexistent files, never prompt-i
Prompt before every removal-I
Prompt once before removing more than 3 files or recursively-r, -R, --recursive
Remove directories and their contents recursively-d, --dir
Remove empty directories-v, --verbose
Explain what is being done--no-preserve-root
Do not treat '/' specially (dangerous)--preserve-root
Do not remove '/' (default)--one-file-system
When removing recursively, skip directories on different filesystems
CAVEATS
rm -rf / or similar commands can destroy entire systems. Modern systems protect against this, but variations may bypass protections.
Removed files bypass the trash. Use trash-cli or desktop trash if recovery might be needed.
Be careful with wildcards. rm \* in the wrong directory is destructive. Use ls to preview what would be deleted.
Root user should use rm with extreme caution. Consider aliases that add -i by default.


