Skip to content

The rm command

Remove files or directories. Deletes files straight away: there is no bin to restore them from. A directory needs -r, which deletes everything inside it as well, so check the name before you press Enter.

Usage

rm [OPTION]... FILE...

Options

-r, -R, --recursiveremove directories and everything in them
-f, --forceno error for files that don’t exist
-d, --dirremove empty directories
-v, --verbosesay what was removed

Examples

  • rm old.txtDelete one file
  • rm *.tmpDelete every file ending in .tmp
  • rm -r buildDelete a folder and its contents

Learn it step by step

learner@sandbox: ~bash (practice)
Note: Try rm here: your home directory has sample files. Press Try beside an example, or type your own.

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.