rm

rm(1) removes files and directory trees. DOS users will notice the similarity to both the del and deltree commands. rm can be very dangerous if you do not watch yourself. Unlike DOS or Windows, Linux does not provide a way to undelete files.

To remove a single file, specify its name when you run rm:

   $ rm file1
   

If the file has write permissions removed, you may get a permission denied error message. To force removal of the file no matter what, pass the -f option, like this:

   $ rm -f file1
   

To remove an entire directory, you use the -r and -f options together. This is a good example of how to delete the entire contents of your hard drive. You really don't want to do this. But here's the command anyway:

   # rm -rf /
   

Be very careful with rm; you can shoot yourself in the foot. There are several command line options, which are discussed in detail in the online manual page.