It’s true: sudo rm -rf kills Ubuntu; a bug report

I’m amazed and bewildered that the sudo rm -rf / command actually worked in Ubuntu. Lowarch (and I can only assume by extension, Arch Linux) screened that command with a terse error message, although it was easily circumvented.

But Ubuntu barely blinked before completely destroying itself. It happened so fast that I barely saw the drive light flicker before the entire business was done in a puff of electronic dust. I tried both 7.04 and 7.10, and both times Ubuntu happily complied.

Even more interesting, the Ubuntu man pages for rm suggest that the default behavior for the rm command (which is part of the coreutils package, if you go looking for it) is not to protect the root directory from removal. Note that there is a --protect-root and --no-protect-root flag, which means you could override the default, no matter what it was.

It doesn’t seem right that Ubuntu should so eagerly self-destruct. To that end I’ve filed a bug report against coreutils, suggesting that the option be reversed, mostly as a protective measure against the malicious posters who think it’s funny to prey on new Linux users.

If you can comment or add to it, I’d be obliged.

42 thoughts on “It’s true: sudo rm -rf kills Ubuntu; a bug report

  1. rufusD

    Sorry, but this is *not* a bug. It’s the same as going “Whoa, if I stick this knife in my stomach it hurts. Hence the knife is faulty” Linux is a *tool* and if one doesn’t know how to handle his tools, things can go wrong.
    Besides, I think “rm -rf ~” is a lot worse than “sudo rm -rf /”. Setting up a new install is done in a few hours (including all customizations), but recovering all my files is impossible

  2. Gerrit

    While you’re at it, better protect all (mounted?) devices from being written to as well. You can dd if=/dev/zero of=/dev/hda, or even adding a redirect character could result in catastrophe: fdisk -l > /dev/hda. And hey – get rid of the shred command too, cause that can do nasty things : shred /etc/* …

    But I don’t really that it is a bug; this is a feature request.

  3. Griz

    Wow, You do know its supposed to do that; don’t you?

    If you are the kind of person who has guns going off by themselves and fires started without cause I suggest doing this in /

    sudo echo ‘-i’ > ‘-i’ ; chmod 000 ./’-i’

    extra credit if you can delete that file.

  4. Luke Maciak

    Btw, this is not some outlandish request. Sun actually altered rm in this way in Solaris 10. I’m not saying Sun is right, or wrong but they did see this as a usability problem and they resolved it.

    So, really the question here is – does Ubuntu community want to stay true to the Unix tradition of letting the user hose the system at will, or implement some rudimentary protection for the sake of novice user.

  5. Rambo Tribble

    Whether bug or feature, safeguards against accidental self-destruction are and expected feature of any consumer product.

    While some of the Linux cognoscenti berate the lack of knowledge exhibited by end users, I’ll bet damn few of them can overhaul an automatic transmission in an automobile. Yet, they will expect that transmission to prevent their starting the car while in gear.

    Those who so roundly criticize the uninformed do so only to effect self-promotion. In so doing they wrap themselves in the shame of vanity.

  6. izi

    @Rambo
    >Whether bug or feature, safeguards against accidental self-destruction are and expected feature of any consumer product.
    <
    man rm

    -f, –force
    ignore nonexistent files, never prompt

  7. UNICRON

    … i agree with many of the posts above, this isnt a bug…. while i did laugh at the fact that ubuntu doesnt protect itself, i also took into account that theyre marketing ubuntu and by association Kubuntu (which i use) to be “linux for human beings”, and therefore while this command may actually have a usability to it, it should at least prompt or require some sort of confirmation before some idiot does it and then starts ANOTHER useless thread somewhere about OMGWTF I FRIED MY BOX… or something equally as annoying….but it certainly isnt a bug… once upon a time… Del C;\*.* worked too…. but it wasnt a BUG

  8. Rambo Tribble

    izi,

    I presume your reply aims to point out that such safeguards as exist for the rm command are intentionally being circumvented by the command syntax in question. While there is validity in such a point, it leaves little room for a typo or other human error, not to mention the malicious designs of the malevolent. For example, the f-key resides in immediate proximity to the r-key, increasing the chances that -rf could occur when all that was desired was -r.

  9. Pingback: Air bag design « Motho ke motho ka botho

  10. Richo

    Rambo, what do you mean when -r was all that was wanted, rm -r / will still hose the system, it’ll just ask you more questions while doing so.

  11. nikopsk

    too bad there is a force command… or not really. well I hope they can fix this.

  12. random-unix-user

    You said you filed a bug report for this?! That’s really disgusting! (sorry, that’s the first word that popped into my mind)

    Please do not ask for Windows practices when using Linux or other Unix-based operating systems.

    I’m not saying that the Windows way is wrong. However, each OS has it’s own philosophy. The Unix philosophy allows the user to do *everything* he wants, as long as he has the necessary privileges.

    In a Unix environment, programs should not impose fake limitations to the user. Let him destroy himself if he desires so! After all, rm is not the only “dangerous” command… As Gerrit said, there are many ways to hose your system, and you can actually delete all your user data even without root privileges. On a desktop machine, user data is more important than the OS itself.

    The command line is a powerful tool; just as nuclear energy, whoever uses it is expected to show some responsibility. Even more when he is the system administrator. And you have to use administrator priviledges to run “rm -rf /”…

  13. William

    In Ubuntu 8.10, Igguess they fixed that with the rm -rf / blockout (“rm” cannot remove the directory ‘/'”).

  14. Pingback: Mother, May I? | Ubuntard.com

  15. The Pinata

    You’re an idiot. IT’S NOT A BUG. IT’S NOT A BUG. IT’S NOT A BUG. IT’S NOT A BUG. IT’S -IX FOR CHRISSAKES.

  16. Elwood

    How about you try this one the next time you decide to do something stupid like erasing your fstree.

    dd if=/dev/zero of=/dev/sd*

  17. kale22

    Dude really?! And it’s not a bug either. If I want to delete my root then I issue the command. I don’t want anything crap that “are you sure” or even worst, I couldn’t even run the whole command. I understand that you have the tools to wipe everything but *you* are controlling the box not the other way around..

  18. Kevin

    Let’s say you want to delete the directory in the variable $oops

    you mistakenly type “sudo rm -rf ${ops}/”. Guess what happens with –no-preserve-root?

    Oops, indeed.

  19. Palo Duro

    If you and others keep suggesting things like this, you will eventually be using a sort of Windows which was, at one time, something more like *nix.

    I’ve only been using Ubuntu for about a year, which makes me a total noob. Still, I don’t run things in command line if I don’t know what it all does, and why, and if it’s all correct.

    In your case, the bug was the user, not something in the OS. Why couldn’t you have suggested a different approach, rather than this kind of alteration? I mean, I see your point, but I hope this isn’t the beginning of a trend in making Ubuntu so “user-friendly” in the way of Windows, that, eventually, no one even learns anything about linux anymore. I hope this is the only time you make such a suggestion. I wouldn’t be the only person to resent your actions if you go on a mission to water down everything you can.

  20. Brian

    yes it sucks that you can hose your system with that command and it complies without even a “by your command”. hopefuly no one will give you the command as a joke but any NOVICE user is smart enugh that any sensitive info is backed up on a regular basis(right?)the most annoying thing is you have to do a fresh install

  21. -f Means Something

    This makes no sense at all. You’re specifying the force option… so why would it ask you anything?!

    If you didn’t put that, it would ask you to confirm each erase…

    Idiot.

  22. unix user

    Oh man,
    what about sudo rm -r /lib*
    OH NOES HOSED
    I think this is going too far. I think it was stupid to do this in Solaris too.
    I think to start going down this path is dangerous, pretty soon we will be stuck with Vista like UACs… for rm
    “are you sure you want to remove this file owned by root?”
    What is the purpose of this, to prevent any command that can be used to hose a system from being run? That is where I see this going a year from now…..

  23. Andrew

    “rm -fr /” isn’t the only one liner that will hose your system. It doesn’t take deletion of all data for that. Are you suggesting that any command capable if destroying a system or deleting all data be annoyingly confirmed by the user in Ubuntu? That extends well beyond coreutils. Are you going to submit bug reports for every program with data-destruction capabilities installable by Ubuntu?

    By the way, someone uninformed enough to paste “sudo rm -fr /” into a terminal just because someone in a forum said to, is also uninformed enough to paste “sudo rm -fr –no-protect-root /” or “sudo rm -fr –HOLY_SHIT_THIS_COMMAND_DELETES_ALL_DATA” or just blindly click “OK” on the manditory dialog box, like most people do anyway with dire results. I fail to see the point.

  24. Scootr

    For Real?!?!?!?!

    that’s sounds like my stupid pickup truck.. I bought a standard shift.. because I want to be in control of shifting… if I didn’t, I would have bought an automatic… yet this stupid truck has a light on the dash that lights up and tries to tell me when to shift.. stupid stupid stupid…

    You are messing with what is most beautiful about *nix the power of the command line. complete freedom to do what ever is within the power of your userid. “but remember, with great power comes great responsibility”… Don’t take the power away from everyone simply because the responsibility scares you.. if you’re scared, stay off the command line.

    1. craig

      @scootr, Well said that man.

      Where could we go next, the stovetop that warns you before turning it on high, a little flag perhaps, stating “dont put your hand on me, Ill be hot”

  25. Jamie

    “Even more interesting, the Ubuntu man pages for rm suggest that the default behavior for the rm command… is not to protect the root directory from removal.”

    By who? root, or a generic user account? Or do you just logon as root and bypass the whole principal of least privilege?

  26. chenno

    “I’m amazed and bewildered that the sudo rm -rf / command actually worked in Ubuntu.”

    At the time you filed your bugreport, Ubuntu 7.04 and 7.10 (the ones you refer to) were shipping an outdated version of coreutils (5.93). –preserve-root was made the default in coreutils-6.3, which had been released for about a year at that time. But instead of simply requesting an update of the Ubuntu coreutils package, you blindly assumed that Ubuntu was responsible for “fixing” what you felt was an Ubuntu bug (you seem to be under the common misconception that Ubuntu is equvalent to GNU/Linux/FOSS, and hence is the correct place to complain and file bug reports for something Ubuntu doesn’t or shouldn’t lay it’s hands on in the first place).

    In a different blog post you argue that other distributions like Arch Linux did already “fix” this bug — they didn’t, they simply shipped a current version of coreutils, trusting that users who wouldn’t like this change would voice their concerns at the right place (i.e. the coreutils developers). Unlike Ubuntu there are distributions who only do what a distribution should be doing — distribute software, vanilla and as intended by the upstream authors, without patching and “fixing” it to death in order to protect their “innocent” (i.e. uneducated) users.

    So, next time you’re “amazed and bewildered”, try to investigate the issue before making blind assumptions and rushing to the wrong place to complain.

  27. schorse

    plz file a bug report against ‘echo’. its the most deadly thing. its bad.. whine whine whine…..

    issue:
    #echo /dev/zero > /dev/sda1
    and guess what? it erases mbr in under 2 ms.

    solution:

    add –preserve-all-things-i-forgot-contemplate to echo

    either that, or i am going to switch over to osx, which is a more secure OS.

    lulz

  28. Glyttch

    If you tell your computer to do something, and it does, wherein lies the bug? I understand that, yes, you managed to wipe your root directory off the map, and yes, it does screw your install, but one more time: If you told it to do it, isn’t it YOUR problem, not a problem with *nix? Should I be suing GM because OnStar doesnt prevent the user from driving a vehicle into a tree at 90+mph? Is there a flaw in the software that the satellite doesn’t know I’m headed for a tree and warn me?

    No, you issued the command, you used the -f flag and insisted that the computer comply… therefore you, not Ubuntu, wiped root. If you order your kids to dive off the roof are you going to ground them for it? Or worse, sue the contractor that built your house for not installing a safety system that would prevent them from having done so? God forbid the devs listen to you and ruin *nix for the rest of us.

  29. Mike

    I don’t see how this is a bug if Ubuntu does exactly what you tell it to do. I personally like being able to do whatever I want on my system. Windows XP, on a default install, will hide the C: drive, the Program Files folder, etc… I just see this being classified as a bug as a similar measure. Not to mention all the other commands listed by other users that will hose your install.

  30. Phil Emerson

    In all honesty and with all due respect, if you didn’t know that rm -rf will recursively remove the files that you tell it to, you shouldn’t have been playing in the terminal window.

    The attraction of Linux to many people (myself included) is that it offers complete control over their computers – something that Microsoft and Apple have gradually taken away (supposedly for the users’ own protection).

    If you need to be told that rm -rf / will delete EVERYTHING in the root, you should stick to the GUI – or at the very least, not use the sudo command unless you know what you’re doing.

    Linux’s power is that it does what you tell it to and if you tell it to do something profoundly stupid, it will do just that.

  31. Luke

    You sir are an idiot, Who would’ve thought that rm deletes things?

    Gosh diddly darn it I deleted a file, You should have the common sense to use a computer wisely not have to be bugged at every turn with an “are you sure?”

    How about next time you cross the road imagine a little hologram “Are you sure?” And as you motion yes towards it realize you just wasted a moment of your life that if people hadn’t ruined it by not thinking for themselves and creating this mothered culture of life for everything everywhere that you could already be on your way, Step up and learn what dangers there are out there and if you fall victim to a mistake learn from it, We all should.

    Maybe you could even write a bug report and get your change reverted before it sticks.

    But anyway, Enjoy your life if you still can..

Comments are closed.