Example uses of the Linux Command rm

An Introductory Tutorial

Man working on computer at desk
Comstock Images/Stockbyte/Getty Images
The "rm" command is used for deleting a file or directory (folder). The command name "rm" is derived from "remove".

To remove the file "accounts.txt" in the current directory you would type

 rm accounts.txt 
To delete a directory named "cases" with all its contents you would enter
 rm -r cases
This assumes that the directory "cases" is a subdirectory of the current directory. The "-r" stands for "recursive".

In order to delete a file that is not in the current directory you can specify the full path.

For example,

 rm /home/jdoe/cases/info
would delete the file "info" in the directory "/home/jdoe/cases/".

You can selectively delete a subset of files using the wildcard character "*". For example,

 rm *.txt
would remove all files that end with ".txt".

Think twice before using "rm". The system may immediately remove the specified files without giving you chance to confirm. And there is no "garbage can" were you can go to retrieve deleted items.