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.

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


  1. 1 Luke Maciak December 6, 2007 at 2:19 pm

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

    alias rm=”rm –preserve-root”

  2. 2 rufusD December 6, 2007 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 December 6, 2007 at 8:41 pm

    What an idiot…

  4. 4 Gerrit December 6, 2007 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 December 6, 2007 at 10:11 pm

    A never ending feature request, I should add.

  6. 6 Dr Small December 6, 2007 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 December 6, 2007 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 December 6, 2007 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 December 6, 2007 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 December 7, 2007 at 2:17 am

    @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

  11. 11 UNICRON December 7, 2007 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 December 7, 2007 at 3:38 am

    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.

  13. 13 Richo December 7, 2007 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 December 28, 2007 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 April 17, 2008 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 /”…

  1. 1 Air bag design « Motho ke motho ka botho Trackback on December 7, 2007 at 9:08 am

Leave a Reply




Welcome!

Most recent desktops


July 21, 2008
Openbox 3.4.7.2 on Crux Linux
1Ghz Pentium III 512Mb PC133


July 19, 2008
Openbox 3.4.7.2 on Crux Linux
550Mhz Celeron 192Mb PC100


IceWM on Arch Linux
OLPC XO-1

Most recent game


Gridwars 2 on Ubuntu 8.04
1Ghz Pentium III 512Mb PC133

Be counted!

License

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

Blogs worth watching

Ubuntu Feeds

Blog Stats

  • 689,306 hits

Categories