What does rm -rf do?
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!
In addition to the previous correct answer, I would like to teach you how to fish:
When you are not sure about how a command works, what options has and what it does, open a terminal and type
man <command>
For example:
man rm
Once in there, you can search for the option. A man page can be really long to read, so in the terminal type:
/<pattern>
So for example, doing:
/-f
You can easily land to:
-f, --force
ignore nonexistent files and arguments, never prompt
After typing /-r
you'll get:
-r, -R, --recursive
remove directories and their contents recursively
You can move between search results using n
(next) and N
(previous).
Bonus:
If you need to do something, but you don't know the command name, use apropos
to search in man pages:
apropos <pattern>
For example:
apropos directory listing
rm
is short for remove.
The r
flag is to remove directories and their contents recursively and the f
means force, and it overrides any confirmation prompts.