Back to the command reference

rm

FilesBeginner In simulator In real Linux

Remove files or directories

Name: rm = remove

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

rm deletes files. There is no recycle bin on the command line and deleted files are usually gone for good, so be careful, especially with wildcards and -r.

Strictly speaking, rm removes a directory entry (a name) linking to the file; the space is freed once no links remain and no process has it open. Deleting needs write permission on the directory, not on the file itself.

Syntax

rm [OPTION]... FILE...

Common options

-r / -R / --recursiveRemove directories and their contents recursively
-f / --forceForce: never prompt, ignore missing files
-iAsk before every removal
-IAsk once before removing more than three files or recursively (less tiresome than -i, safer than nothing)
-d / --dirRemove empty directories too
-v / --verboseExplain what is being done
--one-file-systemWhen recursive, stay on this file system (skip mounted disks)

Examples

  • $ rm notes.txt

    Delete a file

    Explain
  • $ rm *.tmp

    Delete every .tmp file here

    Explain
  • $ rm -r downloads

    Delete a whole directory

    Explain

Related