rm -rf is the Linux command (to be more precise, Unix, but on the Internet it is more associated with Linux). Usually used in the form of “rm -rf / *” (why – see below)
- The rm command itself is to remove (remove) (file (s) and / or directory (s)).
- The -r key – recursively (recursively) – allows you to delete directories with all content, without this key, the command responds “directory is not empty.”
- The -f – force switch doesn’t ask for confirmation (in general, Linux commands don’t suffer from the usual Mazda’s annoying prompting “are you sure?”, This is a rare exception (and that is just because alias rm = ‘is almost always the default in .bashrc) rm -i ‘)). Some side effects of the option are described in mana.
- Unix traditions allow you to combine keys in most programs, which means “-rf” is equivalent to “-r -f”.
- In fact, the key “-rf” is similar in action to the phrase “Everything and all at once!”.
Thus, the essence of the command is to delete a directory recursively, without asking for confirmation. Usually we are talking about “/” – the root directory. Most modern unixes (newer versions of OpenSolaris and GNU / Linux) do not allow a lamer to shoot himself in the leg: rm -rf / do not work. Although everything is quietly removed when using the “–no-preserve-root” key. Kagbe like this: “rm -rf / –no-preserve-root” Kekeke. There is another option: rm -rf / *
FreeBSD understands this command in a slightly modified form: rm -fr /, and in recent versions this thing does not work due to the use of file system flags (they must first be removed – chflags -R −0 /). Depending on the security level of the system, it may be necessary to reboot into single-user mode, which is hemorrhoid.
Windows understands this command as rmdir / s / q C: \ or rd / s / q C: \, where / s is the analog of -r, and / q is the analog of -f. This removes only the contents of the C: drive due to differences in the file system: in small-scale operating systems starting with MS-DOS
Using the command in two ways:
- As a persecution of Linux noobs; [one]
- As a persecution lamers who work in the system, including sitting on the Internet, from under the root. Usually in this case, the treasured line is masked (for the primitive version is only with noobs):
Those who do not understand, will tell Rat-kun: portion of echo "test. test. test. " in fact, it does not affect the execution of the command and is most likely added to put down vigilance. Echo simply displays a message in the console with the text given in quotes – in this case the next line will contain “test … test … test …”
But what happens in the Perl code is not at all obvious due to the fact that it is a voodoo language of deliberately complicated writing. In essence, everything is simple: this line contains only three consecutively executed commands. Let’s make the first iteration and write down the given command as follows:
The second team transmits the contents of the “battery” according to fairly complex rules. In the left part there are four ranges of symbols, in the right – one. If we expand these ranges, we get the following correspondence:
As a result, the contents of $ _ takes the form system"rm -rf /" .
The third team twice (as instructs flag ee) “calculates” the contents of the battery – the above destructive command – and tries to replace the empty string in the battery with the result of this calculation, but the result of the replacement is no longer interesting to the author. More details
There is another option, already for noobs who consider themselves b-linuxoid:
Under Windows-95-98, this patch was still ported and assumed the form deltree / y e: d: c: Why is this disk order? In order to remove the megabytes of the prona first (then they did not measure the gigs), and then the system. It also offered a “universal registry key to get rid of the bluntness of programs,” which recorded this command in Run, and at the same time disconnected the mouse and keyboard. On the next boot, if the user could guess the reason for the strange buzzing of the screw, only a quick, decisive Reset could save (but the user was hypnotized looking at the frozen mouse and remembered the button when it was too late).
Also, an option for new coreutils:
 rm -rf / usr and Bumblebee
A recent example of the occasional use of a meme happened in the summer of 2011 in the Bumblebee project, which is a crutch to support NVidia Optimus technology in notebooks with two video cards. File
This line, as it is easy to see, removes the / usr directory, in which modern Linux contains slightly less than all libraries, binaries, and everything else. The bug was quickly caught and corrected, which did not prevent the project’s bugtracker on github from becoming a forchan affiliate for a few days, with macros, ponies and other things.
 rmdir / s / q C: \ and
In late November – early December 2013, happy users
 rm -rf my-company
Marco Marsala, who was once a hosting provider. Such a small hosting provider with a half thousand users. And he accidentally launched on all servers a bash script containing the line rm -rf /. And everything would be fine, but he forgot to give some values to the variables foo and bar … When Marco came to the IT forum to ask how you can now fix everything backwards, he never managed to get a clear answer, because forum Petrosyans, instead of To sympathize, they vigorously hurried to inform him that he was able to remove his company with a single line of code.
 Barmina Patch
In near-Fidish circles, rm -rf is often called the Barmin patch, in honor of Vladimir Barmin, the UNIX admin. The latter, in the Relkomov news group, answered “how to fix in SCO Unix?” Questions several times with a “universal patch: rm -rf / from the root”.
Based on this patch, a combination was developed, called the Russian Roulette.
Only administrators (root) are allowed to play Russian Roulette, preferably on a server with over 3000 visits per day. As it was found out by the admins of Nyenskans (in practice), this combination works successfully on Linux and FreeBSD in the latest versions of coreutils.
Russian Roulette version for Windows:
This pearl will not work unless you include advanced command processing before this:
And all because in this your Windows it is turned off by default, and you can pull out the variable in the “!” Signs only when it is turned on. Nuff said.
 Barmina Patch and Avaya Corporation
In 2013, the Avaya Call Management System R17 version of the statistics and management system was released, which has finally been ported from these your Solaris to Linux. In particular, it contained a cleanup script, which according to the Hindus had to clean the garbage. At the very end was this code:
A funny effect was found if the / tmp directory was empty. The corporation explained this by saying that in solaris the path for find is mandatory, but in Linux it is not.
 Barmina Patch is Alive
At the end of January 2016, a kind of archkeeper decided to play with this famous patch before re-partitioning his disk. He diligently entered into the team even a special key, without which this patch does not start. Well. and. I got a brick from my MSI netbook – after switching on, even the backlight did not light up!
As it is easy to guess, the patch wiped along with the root also the UEFI variables in NVRAM, which are mounted in / sys / firmware / efi / efivars /, but in principle this could not be a problem, because according to the UEFI standard it should check the integrity of data in NVRAM, and In case of integrity violation, it MUST initialize NVRAM to the default / factory default settings. But here at MSI they decided to forget to check the integrity of NVRAM, and the unlucky arch-wizard dragged his netbook into service.
After this news, there was an epic hitting  on the SystemD developers (and it’s a sin not to quarrel with them, they themselves constantly throw up reasons for quite justifiable abuse in their address): they say, what kind of devil, SystemD mounts these variables with the ability to write !? Let’s quickly remake the mount in read-only mode. To which a reasonable answer was given – utilities need write access, and only the root is allowed to write, which, if desired, premontates these variables in write mode. So, it does not protect against idiots fools "clever men"who are experimenting with the Barmin patch.
The most remarkable thing about this story is that the joke released 20 years ago still shoots, and even with unprecedented power.
There is a more bloodthirsty option sudo dd if = / dev / zero of = / dev / sda bs = 8m, which fills everything with zeros, the probability of saving data is inversely proportional to the response time of the cyant (from the moment you press [Enter] until the command is interrupted by nerve pressing Ctrl + C).
After that, the very first second, even on a cheap mechanical 5400RPM HDD, will nullify 40 megabytes along with the partition table, the loader, and the rest of the file system metadata. And it will never boot without additional hemorrhoids.
In general, it is rather strange that rm -rf defeated the dataset definition in the mass consciousness. After all, it is much more destructive and kosher.
You can, for example, make a hellish scrimer by redirecting the entire hard disk to the sound card.
Or stupidly clog the RAM with random numbers.
It is a pity that there is no pseudo-device for accessing the BIOS firmware, then it would be possible to finally resolve the issue with the red-eyed motherboard (already there , thanks to Pottering for this).