rm
Delete files, or whole folders with -r. There is no recycle bin: learn it safely here.
>_ Try it: a simulated Linux, right herenothing runs on your computer
Loading the terminal…
Examples
-
rm todo.bak -
ls -
rm -v todo.txt -
rm -r old -
rm -f not-there.txt -
ls
How it works
rm FILE deletes a file. There is no recycle bin on a Linux server: once it is gone, it is gone.
A folder needs -r (recursive), which deletes it with everything inside. -f (force) never asks and doesn't complain about files that aren't there, which is why rm -rf deserves a second look before you press Enter.
Syntax
rm [OPTION]... FILE...
Options
| Option | What it does |
|---|---|
-r | delete folders and everything inside them |
-f | ignore missing files, never ask |
-v | say what was deleted |
Good to know
- Run
lswith the same name first: whateverlslists is whatrmwill delete. - An empty folder can go with
rmdir, which refuses to delete anything that isn't empty: a safer habit.