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.

About these ads

42 Responses to “It’s true: sudo rm -rf kills Ubuntu; a bug report”

  1. 1 Luke Maciak 2007/12/06 at 2:19 PM

    Quick workaround – add this to the /etc/bashrc and /etc/profile

    alias rm=”rm –preserve-root”

  2. 2 rufusD 2007/12/06 at 5:38 PM

    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

  3. 3 Michael Magua 2007/12/06 at 8:41 PM

    What an idiot…

  4. 4 Gerrit 2007/12/06 at 10:10 PM

    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.

  5. 5 Gerrit 2007/12/06 at 10:11 PM

    A never ending feature request, I should add.

  6. 6 Dr Small 2007/12/06 at 10:18 PM

    Hmm. Well, Bug or feature request, it still needs to be delt with, and would certain stop the trolls for a season.

  7. 7 Griz 2007/12/06 at 11:13 PM

    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.

  8. 8 Luke Maciak 2007/12/06 at 11:35 PM

    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.

  9. 9 Rambo Tribble 2007/12/06 at 11:40 PM

    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.

  10. 10 izi 2007/12/07 at 2:17 AM

    >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

  11. 11 UNICRON 2007/12/07 at 3:24 AM

    … 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

  12. 12 Rambo Tribble 2007/12/07 at 3:38 AM


    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.

  13. 13 Richo 2007/12/07 at 6:48 PM

    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.

  14. 14 nikopsk 2007/12/28 at 12:43 PM

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

  15. 15 random-unix-user 2008/04/17 at 10:32 AM

    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 /”…

  16. 16 William 2009/01/05 at 1:14 PM

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

  17. 17 The Pinata 2009/04/03 at 12:36 PM


  18. 18 Elwood 2009/04/03 at 1:54 PM

    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*

  19. 19 kale22 2009/04/03 at 3:49 PM

    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..

  20. 20 Kevin 2009/04/03 at 6:10 PM

    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.

  21. 21 cal 2009/04/03 at 10:29 PM

    Okay, -f, force, you do know what this means? Maybe you should go back to win98.

  22. 22 Palo Duro 2009/04/04 at 2:42 AM

    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.

  23. 23 Brian 2009/04/04 at 4:33 AM

    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

  24. 24 -f Means Something 2009/04/04 at 6:12 AM

    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…


  25. 25 kgen04 2009/04/05 at 10:31 AM


  26. 26 unix user 2009/04/06 at 10:04 AM

    Oh man,
    what about sudo rm -r /lib*
    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…..

  27. 27 Andrew 2009/04/07 at 9:21 AM

    “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.

  28. 28 Scootr 2009/04/11 at 5:04 AM

    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.

    • 29 craig 2009/04/11 at 6:04 AM

      @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”

  29. 30 Jamie 2009/04/17 at 12:13 AM

    “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?

  30. 31 chenno 2009/04/20 at 12:10 AM

    “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.

  31. 32 Claymore 2009/04/24 at 3:57 AM

    Bug Report: Ubuntu lets me hit my computer with an axe.

  32. 34 schorse 2009/05/15 at 8:51 AM

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

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


    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.


  33. 35 Glyttch 2009/05/31 at 12:39 AM

    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.

  34. 36 Mike 2009/06/04 at 4:16 AM

    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.

  35. 37 poorguy 2009/06/25 at 1:59 AM

    what a poor guy…

  36. 38 Phil Emerson 2009/06/26 at 7:37 PM

    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.

  37. 39 Luke 2009/09/05 at 8:24 PM

    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..

  1. 1 Air bag design « Motho ke motho ka botho Trackback on 2007/12/07 at 9:08 AM
  2. 2 Mother, May I? | Trackback on 2009/04/03 at 9:54 AM
Comments are currently closed.


Visit the Wiki!

Some recent desktops

May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF

May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games

Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers


This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,957,873 hits



Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: