The rm command removes files and directories. You must use the -R option to recursively remove files, subdirectories, and the parent directory itself.


The syntax of the rm command is:

# rm [options] {file/directory names}

For example, to remove the ~/myfiles directory and its contents:

rm Command Examples

1. To remove a file:

2. To forcefully remove a file:

3. To prompt before removing any file:

4. To prompt before removing any file, if more than three files:

5. To prmpt as specified:

# rm --interactive=WHEN file* 

6. To skip any directory that is on a file system different from specified:

7. To do not treat “/” specially:

8. To do not remove “/”:

9. To remove directories and their contents recursively:

# rm -r
# rm -R
# rm --recursive 

10. To run in verbose mode:

11. To get the help:

12. To get the version: