Ubuntu – What does rm -rf do

deletedirectoryfiles

What does rm -rf do when used to remove files or directories?

How do the -r and -f options work together?

Best Answer

The command rm -rf is the same as rm -r -f.

From rm's man page (type man rm in a terminal to see it) -r does:

remove directories and their contents recursively

And -f does:

ignore nonexistent files and arguments, never prompt

So in combination they do both.

In fact it is a very dangerous command because it will recursively remove everything within the directory you choose (or just remove the file you choose), and it will do so without ever prompting you.

Please use this command with care!