1. Name

rm [man page] - remove files or directories

2. Synopsis

rm [OPTION]... FILE... 

3. Frequently used options

-i, --interactive
prompt before any removal
-f, --force
ignore nonexistent files, never prompt
-r, -R, --recursive
remove directories and their contents recursively

4. Examples

Interactive remove is very useful option.

rm -i 

interactive rm option prompts before overwrite
rm -f ( force) option removes also files which are non-existent and never prompt.

rm -f 

rm force -f option

Even that rm command was not constructed to remove directories by default you can force rm to remove directory and all files in inside by -fr option combination. Be very careful with this command it can do lots of damage:

rm -fr dir/ 

rm - force remove files and directories

Sometimes you need to make rm command to do not accept any other options. Lets assume that we have a file called "-i" and we need to remove it. In this case we nee to use "--" options wich will instruct rm command to not accept any other options.

rm -- -i 

rm - do not accept more options
Or we might need to remove filename which starts with meta character. In this case we need to escape this meta character with "\". For example to remove $rm file we issue command:

rm \$rm 

rm files with meta characters

Free Linux eBooks

Do you have the right skills?

Our IT Skills Watch page reflects an up to date IT skills demand leaning towards the Linux and Unix environment. We have considered a number of skills and operating systems.

See the result...

Linux Online Training

Learn to run Linux servers and prepare for LPI certification with Linux Academy. 104 available video lessons with PDF course notes with your own server!

Go to top