What does rm do?
rm permanently deletes files. With -r it deletes folders and everything in them. Linux has no recycle bin, so deleted files are gone.
rm [options] file…
Most useful options
| Option | What it does |
|---|---|
| -r | delete folders recursively |
| -f | force: no questions, no errors |
| -i | ask before every file |
| -v | show what is deleted |
rm examples
In security work
Never run rm -rf with a variable that might be empty (rm -rf $DIR/) — it can wipe the whole system.
Questions about rm
Can I recover a file deleted with rm?
Not easily — there is no trash. Forensic tools can sometimes recover data, but take backups instead.