Skip to content

rm

11 commands

Removes files and directories. There is no recycle bin — deletion is immediate.

  • files
  • deletion

Install rm

sudo apt install coreutils

Files6

rm <file>

Deletes a file. There is no undo.

Link
rm -i <file>

Asks for confirmation for each file.

rm -I <files>

Asks once before deleting more than three files.

Link
rm -f <file>

Forces deletion without prompts and ignores missing files.

rm -- <file>

Use -- to delete a file whose name starts with a dash.

Link
rm -v <files>

Prints each file as it is removed.

Link

Directories4

rmdir <dir>

Removes an empty directory only — a safe choice.

Link
rm -r <dir>

Removes a directory and everything inside it.

Link
rm -rf <dir>

Recursive and forced. Double-check the path; never run it with an unquoted variable that might be empty.

Link
find <dir> -name "<pattern>" -delete

Deletes matching files anywhere in a tree.

Link

Secure deletion1

shred -u -n <passes> <file>

Overwrites a file before deleting it. Not reliable on SSDs, copy-on-write or journaled file systems.

Link