Eight characters. That's all that stands
between you and your entire digital world being absolutely wiped out. It's a
command so destructive that it's caused hundreds of millions of dollars in
damages, data loss, bankruptcies, and almost caused Toy Story 2 to be lost
forever. The command we're talking about is rm hyphen rf forward slash. So, what
does rm hyphen rf forward slash actually
do? Let's break it down like we're diffusing a bomb.
Which honestly we kind of are.
UNIX commands follow a simple structure. First, the command name. Then, flags
that modify how it behaves, followed by arguments that tell it what to act on.
So, let's diffuse this bomb piece by
piece. RM is an abbreviation of remove. It's
the UNIX command for deleting files, which means it works on Linux, macOS,
and other UNIX-based systems. [music] Although, on Windows, rm is also the
alias for the remove item command in PowerShell, which does similar things.
Hyphen r is what's called a flag in a UNIX command. It's an option for how you
want the command to behave. In this case, the r stands for recursive, which
means instead of just deleting files in one folder, it descends into every
subdirectory and deletes everything inside them, too. All the way down the
tree. yeah, I accidentally executed it.
Okay, so there's no way to reverse it. Yeah, it was my personal computer.
I I wedding photos, baby pictures, Bitcoin
wallet passphrase. Oh, I'm going to be in so much trouble.
Um so, uh so, after the r flag is the f
flag, which stands for force. This means it deletes files even if they're marked
do not delete, and it doesn't ask for confirmation or stop for errors. It just
goes, like you just saw on my personal computer. It didn't even ask if I was
sure. It was Then comes the argument part of the command, which tells it what
you want deleted. Now, in this case, we're putting a slash, which means the
root directory. In Linux, that's the very top of your file system, where
everything on your computer lives and every other directory stems from. If
you're a Windows person, your closest equivalent is C, but it's actually worse
than that. Linux mounts everything under root, including other drives and
devices. There's no escaping to a D drive here. Then, once you hit enter,
Yeah, so, see, the new machine we set up for you,
you deleted the whole file system.
And there's no way to get it back? No. No way to get it back. Okay. All right.
Okay.
So, all together, this is basically telling your computer to delete
everything everywhere and not to stop or ask questions while it's doing it.
That's a key point. The command starts at the top of your file system and works
its way down, deleting system files, user data, configurations, everything.
And here's the eerie part. While you might think your computer would
immediately become unusable, it actually keeps running for a while, because the
programs in memory still work until they need to access something that's been
deleted, and then stuff starts to fall apart. Now, you might be wondering,
reasonably, why does such a dangerous command even exist? To find out, we
talked to Matthew Garrett, a Linux kernel developer who spent years working
on firmware security. He's one of the people who's actually had to deal with
the fallout when this command goes wrong. >> It's not really a deliberate design
choice. Everything in Unix is a file. Slash is just the root of your entire
file system. RM doesn't care. It just sees, "Oh, you gave me a directory."
Sometimes you make a chainsaw, you don't really think of this as a "Someone could
destroy their house with this if they tried." You think, "I made a thing to
cut down a tree." Matthew's right. System administrators need a way to
quickly clean up entire directory trees when managing servers, removing old
installations, or wiping test environments. And we know what you're
thinking here. Riley, you practice backup best practices, of course.
>> Just restore. Well, sometimes backups
fail. In fact, let me tell you about the time Pixar almost lost Toy Story 2. It
happens to everybody. >> In 1998, someone at the studio ran a
variation of this command on their animation servers. The associate
technical director, who had been reviewing the character assets at the
time, watched in horror as in a matter of seconds the entire file system
disappeared. >> When they tried to restore the files from backup, they realized their
magnetic tape-based backup system had reached its 4 GB size limit. And since
Toy Story 2 was a whopping 10 GB,
>> [snorts] >> the backups were overriding themselves without anyone knowing. So, how did Toy
Story 2 survive? Did they have to remake the whole thing? I'll tell you that
after I tell you about today's sponsor, Odoo. They make it easy to wrangle up
all the aspects of business management into one platform. Whether that's CRM,
project management tools, invoicing, running a forum, it can be all done with
Odoo. It has a user-friendly and customizable
interface, so you can make sure it suits your needs best. And if you only end up
needing a single application, Odoo's free.
You can even book a demo with them before you decide to try it. So, use our
link for a free 15-day trial with no credit card required. Now, back to
Pixar's nightmare. One of the only things that saved Toy Story 2 was this.
Supervising technical director Galyn Susman had just given birth and had a
copy of the film she had been working on during her maternity leave on her home
workstation. So, thanks to her diligence and America's horrible maternity leave
laws, the world got Toy Story 2. Now, you might think, "Okay, well, I just
won't back up to magnetic tape anymore. I'll try one of these experimental
newfangled backup methods, like the cloud or hard drives. Then, I can just
reinstall my operating system and restore, right? Wrong, potentially. In
2016, users discovered that on some systems with UEFI firmware, the
successor to BIOS firmware that became popular in 2012, running rm -rf/ could
permanently brick your motherboard. And you can't install Linux on a brick. I
mean, look at this thing. It doesn't even have any ports. So, how did this
happen? Some Linux systems expose your firmware settings as files in a special
folder. Things like which drive to boot from, your security keys, and even what
hardware your motherboard thinks is plugged in. In the old days, your
firmware settings were stored in a small amount of non-volatile RAM EFI
variables. They're stored in the same flash chip that your firmware is stored
in. When rm -rf runs, it deletes these
firmware variables, too. On poorly designed motherboards, this literally
destroys the motherboard's ability to start up. Vendors, it turns out, had had
in some cases used runtime variables for critical data, and they would not have
error checking codes. They would assume that that was there. And if the if the
variable wasn't there, instead of recreating it with default values, the
firmware was either just stop, or it crash. A user ran the
command on their MSI notebook in 2016, which led to a deletion of the EFI vars
directory, which contained the secure boot keys for the system. As a result,
the user couldn't even boot into the BIOS. All from typing eight characters.
And before you freak out and flee the Linux Republic to supplicate at the
altar of Gates or Jobs, modern Linux
systems have put protections in place to avoid accidental deletion of your entire
computer. Linux has the concept of immutable files, files that can't be
modified. Even if you have write permission, you can't change an
immutable file. And what we did was
set most EFI variables immutable by
default. This is a pretty elegant solution. I did not come up with it. I I
don't really do elegance. So far, we've been talking about accidental executions
of rm -rf, but this command is also prone to malicious deletions. In 2013,
there was a 4chan campaign where trolls were telling Mac users that this command
would activate hidden Bitcoin features on their machines. Who would have
possibly guessed that 4chan, the wholesome community that innocently
popularized Pepe the Frog, would be the source of malicious trolling?
Fortunately, the Linux community takes this kind of trolling seriously. Most
help forums ban users immediately and permanently for trying to trick
vulnerable users into executing rm -rf.
Hell yeah, Linux community, that's the spirit. Not like those trolls over on
4chan. It's also harder than before to
accidentally execute this command without knowing you're doing it. Since
2006, the command won't work on the root directory without adding the no preserve
root flag. [music] Think of it like a safety on a gun. But, rm -rf forward
slash asterisk still nukes your system.
That little asterisk makes the command execute on each directory individually,
bypassing the root directory protection. Which, extending our earlier metaphor,
is like if your gun also had a second trigger with no safety on it. And, as
cool as a double trigger, no safety gun
might be, it's not ideal for a command that could destroy all of your wife's
pictures of her niece. >> [clears throat] >> Which is why you want to make sure
you're using backups, and ideally using file system snapshots with something
like ZFS or BTRFS, which lets you roll
back changes like nothing happened. So, how do you actually protect yourself
from this nightmare? First, if you use Linux,
>> [music] >> there's a tool called safe rm that maintains a deny list of directories
that can never be deleted. You can also set up aliases to make rm always ask for
confirmation before deleting, and keep good backups. Follow the 3-2-1 rule.
Three copies of your data in two different types of media, with one copy
stored offsite. And maybe,
just maybe, double-check your commands
before hitting enter. Because the difference between rm {hyphen} rf/folder
and rm {hyphen} rf/space folder
could be your entire digital life. And speaking of backups, if you want to
learn more about how to protect your data, our video on RAID file systems
will teach you everything you need to know. I am going to go buy a new laptop.