rm

Delete files, or whole folders with -r. There is no recycle bin: learn it safely here.

>_ Try it: a simulated Linux, right here
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

OptionWhat it does
-rdelete folders and everything inside them
-fignore missing files, never ask
-vsay what was deleted

Good to know

  • Run ls with the same name first: whatever ls lists is what rm will delete.
  • An empty folder can go with rmdir, which refuses to delete anything that isn't empty: a safer habit.