Example Uses of the Linux Command rm

A Short 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 
rm -r cases

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

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

 rm *.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" where you can go to retrieve deleted items.