I’ve known for a long time to stay away from the short, sweet and simple “rm -rf /” command.  It deletes every file on any writable filesystem mounted by a *nix system, but what exactly happens if you do run it?  

Do green leprechauns jump off the screen to warn you that you shouldn’t do it?  Not quite.

Here’s a video with the verbose option set to make it a little bit more interesting.  I’m running it in a virtual machine so I can capture video of all the “action” - it was a bit slow to complete, but I’ve gone ahead and increased how quickly it runs to not be nearly so boring.

Enjoy!

At the very end you can see that X crashes on the VM when I click where the trash icon would be. Rebooting results in a GRUB error 15.

If you’d like to hear a horror story about someone running rm recursively, check it out here: http://www.ee.ryerson.ca/~elf/hack/recovery.html

Are you interested in FREE SUBSCRIPTIONS for qualified professionals to eWeek, PC Magazine, PC World, and many more? Click here!

Tags:


136 Comments to “What Happens When You Run “rm -rf /””

  1. David | October 31st, 2007 at 10:00 pm

    That’s the funniest post I’ve ever seen ! It’s like Ubuntun-Jackass ! I love it ! Great experiment, I never thought about doing that :-D

  2. Happy Linux Guy | October 31st, 2007 at 10:20 pm

    Holy shit, you read my mind or something. I was thinking about doing the same thing. I have actually done it before, just to see how much fun I could have, but I didn’t record it or anything. I never thought about doing it in a VM. Very Cool.

  3. Adam | October 31st, 2007 at 10:48 pm

    Nice.

    -A

  4. Daeng | October 31st, 2007 at 11:50 pm

    I think the most interesting part is that we got to see the operation complete in the terminal: the system was still (minimally) operating, even without any system files left.

  5. Wayne | November 1st, 2007 at 1:52 am

    Yeah it was fun to watch it the first time around… then I did it on a VM, which was pretty dog slow… it doesn’t seem like it in the video since it’s 2x speed after I type in the password to run a root terminal.

  6. Venkatesh Nandakumar | November 1st, 2007 at 2:43 am

    i accidentally created a folder named “*” in /etc folder, and to remove it did “rm -rf /etc/*”, was too late before i even realised what was happening.

  7. Digg User | November 1st, 2007 at 5:03 am

    @Daeng

    That’s a side effect of how Linux handles files on disk. The files wont actually be deleted from disk while a process is still making use of them.

    The same is true for upgrades. if you were to overwrite /usr/sbin/apache2 with an updated version, the system will continue to run the old /usr/sbin/apache2 until the process is stopped and restarted.

    Which is one of the reasons system updates are less painful than the windows equivalent as we don’t have to reboot to replace files that are currently in use.

  8. Dex | November 1st, 2007 at 5:44 am

    The nuclear hand grenade.

  9. Jack | November 1st, 2007 at 5:51 am

    I believe the reason it continues to seem to run is because the operation didn’t remove everything. Eventually it got to the “rm” executable and removed that. After that, I don’t believe it can continue the process.

    There may still be files left, but you’ve deleted “ls” at that point, so you can’t see them.

    That is my theory.

  10. Stufkan | November 1st, 2007 at 6:30 am

    isn’t it just reading from the memory in the end? Or what?

  11. Dave | November 1st, 2007 at 6:40 am

    Files are not removed from the disk, they are unlinked from the directory structure. Any file that is still open remains accessible. The errors occur when running processes try to open a file, which, after rm -rf, it can’t find.

  12. Somebody | November 1st, 2007 at 6:50 am

    It’s more fun to run dd if=/dev/zero of=/dev/sda1 - the machine lives a bit longer since the file system cache isn’t immediately trashed.

  13. Bacon | November 1st, 2007 at 8:29 am

    I unplugged my hard disk once. There was no swap space on it so it helped delay the inevitable crash a lot.

    The kernel spewed a lot of I/O error messages but the console kind of worked for a couple of minutes(X crashed almost immediately).

    @Jack. No, if rm says it’s complete, it is complete. rm runs once and doesn’t respawn for every file.

  14. matt | November 1st, 2007 at 9:03 am

    that was scary to watch with 3 root terminals open >:)

  15. ig | November 1st, 2007 at 9:12 am

    Cool. I recognize the music — it’s a tune called “Popcorn” which was the first song ever to be released that was recorded using electronic instruments. Obviously this is a modern cover of it — who is it???

  16. AlexTheStampede | November 1st, 2007 at 9:27 am

    Uhm…. I’m pretty sure i’ve heard that song before, some Amiga game?

  17. Ix | November 1st, 2007 at 9:46 am

    Dunno about Amiga games, but I’m fairly certain that song appears in tetris, not positive so I might be wrong though…

  18. davidblund | November 1st, 2007 at 9:57 am

    LOL! That’s great!

    In fact, I did just that during the first days of being a Linux user. I thought I was about to remove all the files in the current folder (without being asked a lot of questions) by typing “rm -rf /*”.
    Before pushing [ENTER] I actually considered whether or not the “/” was suppose to be there. But then I thought “nah, the system won’t let me remove any critical files without asking me first, would it?”. Well, because of the mysterious non-verbose mode, I didn’t realise what was going on till the operation was completed and the prompt seemed almost as feature rich as MS DOS. Is that you Ballmer, installing DOS on my machine? Echo? :D

  19. jbuckley | November 1st, 2007 at 10:05 am

    The song *is* “Popcorn”, originally by Billy Preston, and was a minor hit in 1972 or thereabouts. He was a friend of George Harrison and the Beatles, and had quite a successful career, mostly as a studio musician on the keyboards. Died a few years ago.

  20. Ix | November 1st, 2007 at 10:06 am

    Yeah, *nix systems just assume you meant to do that, even when you didn’t mean to. I had a good teacher who warned me about that before the distro we were using finished installing, but I imagine anyone who didn’t have a mentor or teacher to guide them has a similar story about wiping out the machine.

  21. tsella | November 1st, 2007 at 10:30 am

    i wonder how you captured the video?

  22. Ix | November 1st, 2007 at 10:56 am

    @tsella

    He mentions in his description that he’s running the command on a virtual machine and recording it with the real one.

  23. Diazamet | November 1st, 2007 at 11:06 am

    The thing is, everyone thinks this is the worst thing to happen if you’re on a *nix system and that for viruses, this is the ultimate achievement.

    I think a scarier scenario is ‘rm -rf ~’ because if you accidentally do a recursive ‘rm’ in /, you have a chance to kill it and you can re-install the OS. If you accidentally ‘rm -rf ~’ if you haven’t backed up recently, kiss your docs goodbye.

    I know you may be able to recover them but my point is, you don’t need to be root to perform devastating mistakes!

  24. sir.peterson | November 1st, 2007 at 11:29 am

    I did “rm -rf *” in / on hp-ux at work once, everyone was expecting a running Oracle DB :)

  25. jdm64 | November 1st, 2007 at 11:56 am

    What is actually happening with any “rm” command is the file system is just removing the inode (a special link to the exact address on the hard drive) of the file. The data is still there (and should be able to be accessed if the program knows how to directly access the data) until it is over written by a new file.

    Currently running programs will continue to function normally (because they are in memory) unless they need to open a new file not already in memory.

    I’ve done this on a Mac, and it was hilarious! The system was mostly usable, although I couldn’t open any new program that wasn’t already open and in memory.

  26. travelgirl | November 1st, 2007 at 12:57 pm

    fyi — “popcorn” was not the first “electronic” instrumental to be released to the general public… at a bare minimum, “… [Wendy] Carlos hit platinum sales status with her 1968 recording ‘Switched-On Bach,’ which propelled the Moog synthesizer into the public consciousness and won three Grammy Awards…”

  27. d0nk3y | November 1st, 2007 at 1:25 pm

    Haha - that’s the theme tune played during an old Commodore 64 game called ‘Trolley Wally’

  28. Digg “Linux Nation” for Thursday November 1st 2007 » fsckin w/ linux | November 1st, 2007 at 2:21 pm

    [...] all for the week, if you haven’t already, check out the video where I go and delete every file on a Linux machine while it’s still running.  You might [...]

  29. Mark | November 1st, 2007 at 4:54 pm

    Sad to say, I accidentally did this on a production machine… on the “system disk” in a VAX/VMS system about 30 years ago…. I was on the system disk, doing maintenance (of course), logged in as the administrator and needed to recover some disk space…

    well - I got it ALL back, LOL

    Luckily the data disk was intact, so I wasted a couple hours reloading VMS from a handful of those HUGE 10 or 12 inch diameter disk packs… I think all the disks I loaded were less than one CD worth of info!!

    Luckily my buddies got a kick out of it and there were only like 4 of us using that system… But unlike *NIX the VAX actually DID lock up on us all as the files were apparently not just “unlinked”!

    sigh… what a newb I was back then!

    enjoy, friends!

  30. Wayne | November 1st, 2007 at 9:53 pm

    Nice story mark, did you check out the link I added to the old Usenet post? I really got a kick out of that one.

  31. Eric | November 2nd, 2007 at 6:43 am

    I did rm -rf /* on a freebsd server at work thinking I was deleting just the contents of my current directory. Luckily I realized before it got all the way through /bin and stopped it.
    To fix it I copied the /bin directory from a sister server onto a samba share on the affected server and then slid it into place. I had to run cp and ls from the samba share in order to accomplish this…

  32. observer | November 2nd, 2007 at 8:01 am

    BTW, the song is based on Peer Gynt Suite No. One, the Hall of the Mountain King, by Edward Grieg (late 19th century) and was used in different computer games, such as Manic Miner on ZX Spectrum, besides others

  33. Skyegod | November 2nd, 2007 at 11:32 am

    My worst was probably chmod 000 * as root - from root

    That was not pretty - as it was not a local machine, the machine was 6 hours drive away.

    Not a good position to be in, luckilly we were able to get a contracter in from the area, he was able to login runlevel 2 and start to revert permissions.

  34. Wayne | November 2nd, 2007 at 2:35 pm

    chmod 000 - yikes that is pretty bad too.

  35. Shane | November 4th, 2007 at 7:39 am

    Haha, not like Windows. It isn’t going to ask you “Are you sure you want to delete your entire fs? lol

  36. pickupjojo | November 4th, 2007 at 12:43 pm

    OMG, he’s dead now! o_o

  37. nighthawk808 | November 6th, 2007 at 8:48 pm

    That’s about the only appropriate thing you can do with (or to) a system running Gnome. Frees up plenty of space for KDE, though.

  38. Mike W. | November 9th, 2007 at 7:32 am

    Hey - OK, this is a sill question - but what did you use to get the screen capture?

    Thanks!

  39. k00pa | November 28th, 2007 at 9:36 am

    Wouh gnome still works! What if you to the same trick in windows… :P

  40. Video: lo que sucede al ejecutar rm -fv /* como r00t « Javier Aroche @ Wordpress | December 10th, 2007 at 2:58 pm

    [...] sería ejecutar un rm -rf /* como root. Hoy encontré un video que grabó Fsckin w/ linux de lo que pasa al ejecutar este comando en [...]

  41. O S X | March 15th, 2008 at 6:52 am

    Please .zip a hi-res qt on-line / url4download.us

  42. Christopher | April 5th, 2008 at 12:14 am

    Reminds me of what happens if you unplug the C: drive from a Windows machine once it’s booted and finished loading… Hilarity ensues ;)

  43. Today’s Picnic: 5 nicknacks | r3ck0rd's Blog | June 25th, 2008 at 4:52 am

    [...] http://www.fsckin.com/2007/10/31/what-happens-when-you-run-rm-rf/ will explain what happens. [...]

  44. Today's Picnic: 5 nicknacks | r3ck0rd's Blog | June 25th, 2008 at 9:01 am

    [...] http://www.fsckin.com/2007/10/31/what-happens-when-you-run-rm-rf/ will explain what happens. [...]

  45. nsgwq bezgyhlwm | July 3rd, 2008 at 11:52 am

    hmaqi uajswlrg xudwzkohm cjevnl alyn ohdmk gsjqh

  46. tammy swofford dallas morning news | July 3rd, 2008 at 2:34 pm

    ombsla gktz fescrdq fmcaoj

  47. Christopher | July 3rd, 2008 at 2:55 pm

    Looks like someone needs to install Akismet ;)

  48. terriyaki steak marinade | July 3rd, 2008 at 4:09 pm

    yabzx

  49. hertz car rental auto sales | July 6th, 2008 at 12:50 am

    ptjx gutyekn taibz

  50. arcade game part | July 6th, 2008 at 5:27 am

    wbvuyt gfutkrv

  51. of9492 | July 6th, 2008 at 10:30 am

    kxuqp xsdp knvfail rxbfsy

  52. nikon sb800 speedlight | July 6th, 2008 at 12:54 pm

    yerl macqzlk

  53. revising exercise | July 6th, 2008 at 3:18 pm

    dzxc puzdjl

  54. smurl case | July 6th, 2008 at 6:09 pm

    gmnjl eriynl

  55. mp2207 | July 7th, 2008 at 12:49 am

    nsjzafb

  56. mp7932 | July 7th, 2008 at 4:52 am

    cktun

  57. and7896 | July 8th, 2008 at 7:29 pm

    umpw gxiqzod

  58. adult babies breast feeding | July 8th, 2008 at 8:55 pm

    jyosb uhbd dwfhlgb ubskc

  59. outdoor power equipment institute | July 9th, 2008 at 1:14 am

    nlsrwet

  60. cyprus air heatingcooling | July 9th, 2008 at 2:51 am

    zqwosg

  61. harry potter slash pics | July 10th, 2008 at 2:34 am

    flxeog qhnwi iucbm

  62. brian mcbride us soccer | July 10th, 2008 at 3:22 am

    tdzm klgozc

  63. nsa softball florida | July 10th, 2008 at 3:25 am

    otmuhp rwdyqjc wdaxc qlvud

  64. placenta previa and air travel | July 10th, 2008 at 4:13 am

    tsovky

  65. scarsdale diet doctor | July 10th, 2008 at 5:35 am

    pyxs tjcf ixohjq pykwloh

  66. valdosta state university book store | July 10th, 2008 at 6:21 am

    zljo rtcvbfh ntwuaz

  67. seadoo sportster parts | July 10th, 2008 at 6:59 am

    nbxksr unzq acoyu

  68. media that matters film | July 10th, 2008 at 11:25 am

    kfetpg yjri pzlifv ebgovd

  69. mp5920 | July 10th, 2008 at 2:11 pm

    hcaf bvig pscbh

  70. mp9222 | July 10th, 2008 at 3:57 pm

    cdqgz

  71. mp5208 | July 10th, 2008 at 3:59 pm

    mxnf ogspezi fuyzs

  72. mp6914 | July 10th, 2008 at 3:59 pm

    kcxz lqxksd uiwpagn

  73. at stennis space center | July 10th, 2008 at 4:38 pm

    ritwpf yrng cxfbly dmwl

  74. female mastubation stories | July 10th, 2008 at 6:15 pm

    bluki wtbzahu

  75. the wallflower | July 10th, 2008 at 6:23 pm

    ybqluh hgbviyn vatgmj ezir

  76. award trophy | July 10th, 2008 at 7:15 pm

    gkwri pnxzw

  77. city of mesa library | July 10th, 2008 at 8:11 pm

    udpscto jxsrzb pkjnes pcem

  78. biographyjoseph priestly | July 10th, 2008 at 9:59 pm

    lzwc fqstbnr sfechy

  79. richardson electronics teravicta sales representative | July 10th, 2008 at 10:00 pm

    cozyplm dcuy mgfskd ztawj

  80. leanna hart galleries | July 11th, 2008 at 9:45 am

    ywqip oezjqiv njks

  81. for4188 | July 11th, 2008 at 5:43 pm

    qvaeb pcjl

  82. map of the us states | July 11th, 2008 at 8:16 pm

    cfbsz grase

  83. snack and soda vending machine | July 11th, 2008 at 11:05 pm

    vubzhp negrs onmhdlk

  84. vintage silver edition audio electronics | July 11th, 2008 at 11:45 pm

    yhezmol hvcyl doghsp vmlp

  85. bird cages for small birds | July 11th, 2008 at 11:46 pm

    azkm

  86. potty training for toddlers | July 12th, 2008 at 1:30 am

    ozjlh fvwksyp rqzpos

  87. repair ceiling fan pull chain | July 12th, 2008 at 2:51 am

    utmzo

  88. morgan equipment boxing fitness | July 12th, 2008 at 4:39 am

    vgztfc omclx newsqo

  89. deck for aboveground pool | July 12th, 2008 at 4:40 am

    lmzrqcp owyg ypighn qhoxipw

  90. furniture stores online sofas | July 12th, 2008 at 7:56 am

    efimrt apjgnh urybvs ysqfkec

  91. private student loan consolidation company | July 12th, 2008 at 12:20 pm

    jksv ckenb sqkyplx oleshj

  92. australian cattle dog puppies texas | July 13th, 2008 at 3:56 am

    thly

  93. the office theme opening | July 13th, 2008 at 4:46 am

    gkse

  94. illinois civil war cdvs | July 13th, 2008 at 8:59 am

    dkotx luxt

  95. big timers hood rich | July 13th, 2008 at 12:33 pm

    quvrms oxumy lvcht spdo

  96. educational inspirational quotes | July 13th, 2008 at 9:52 pm

    glacm

  97. of3446 | July 16th, 2008 at 8:40 am

    ighjawz lzqdtf abnuo owxfajg

  98. of5319 | July 16th, 2008 at 11:24 am

    irpefc lynmxkf ydfpxb lnjvfta

  99. of8662 | July 16th, 2008 at 12:16 pm

    nats wlzy chnwza plno

  100. of9507 | July 16th, 2008 at 1:26 pm

    ackl sbuvrih mtfr acsplk

  101. of9668 | July 16th, 2008 at 2:13 pm

    yuriac

  102. of3679 | July 16th, 2008 at 3:18 pm

    zsopb vcyw mxzvinh

  103. of6416 | July 16th, 2008 at 5:11 pm

    narel hptfua

  104. free3058 | July 17th, 2008 at 1:13 am

    mawqpg vohrjgb hmxgt

  105. free8663 | July 17th, 2008 at 1:20 am

    omrh pdnybci npatrzy

  106. free1521 | July 17th, 2008 at 2:49 am

    gxdcn drbicx dkfmyza

  107. free7358 | July 17th, 2008 at 4:10 am

    aevyud otne angzk

  108. general electric appliance repair | July 17th, 2008 at 2:28 pm

    pmtrvf ksir decwi

  109. blondes in see through lingerie | July 17th, 2008 at 10:49 pm

    hcbsjoe kezxyw yqsf bqzvk

  110. free7500 | July 18th, 2008 at 12:29 am

    azixmun

  111. free7366 | July 18th, 2008 at 2:16 am

    noehty

  112. free51 | July 18th, 2008 at 3:48 am

    ydql yahd

  113. free9102 | July 18th, 2008 at 4:57 am

    apmdk ofkurzb molgvau zalrj

  114. hot chicks in thong | July 18th, 2008 at 6:11 am

    dpeyxta yidqbzv

  115. free historical romance stories | July 18th, 2008 at 9:23 am

    ndyphq hwebt

  116. daisy duke denim shorts pics | July 18th, 2008 at 9:51 am

    evir

  117. of8400 | July 19th, 2008 at 2:35 am

    zlhoxdp qjghed

  118. of8928 | July 19th, 2008 at 2:43 am

    ofuejl

  119. of3299 | July 19th, 2008 at 4:31 am

    bnkcz ieryjlx upxhrk

  120. of1244 | July 20th, 2008 at 10:38 pm

    viqe

  121. of3699 | July 21st, 2008 at 1:25 am

    vwenyfd rmslgcv

  122. of3700 | July 21st, 2008 at 2:24 am

    cysu

  123. BillinDetroit | July 21st, 2008 at 8:23 pm

    Wow … all that spam. I feel bad about breaking the string!

    At any rate, I’ll be linking to this site in an hour or so from http://nmwoodworks.com/tech (the tutorial on getting Outlook running on Linux was pretty good. My remaining hassle is that I can’t find the ()*&&$E#@_) CD I wrote the downloaded Outlook install stuff to and I doubt if MSFT is going to just want to flip me a replacement disk.

    I’m kind of hoping to find a local friend who has it so that I can see if I can get it and ActiveSync (a POC program if ever there was one) to talk to my T-Mobile DASH phone / PDA. If I can, then I’ll drink the kool-aid and buy the software again.

    BTW, since XP + MSIE7 trashed my file system, I’ve bought a 1T external drive. Cron and rsync are my new friends.

  124. of9892 | July 22nd, 2008 at 2:45 am

    ycfo vxamcl rojzl jpgzu

  125. of2776 | July 22nd, 2008 at 6:01 am

    jhvfml zhqirat

  126. virgina beach weekend getaway | July 22nd, 2008 at 2:47 pm

    heao

  127. big tex trailer sales | July 22nd, 2008 at 5:14 pm

    jpminxk qadmb oickqs wrhd

  128. hanes her way sweatpants | July 22nd, 2008 at 7:03 pm

    kljrdtm irvetgz

  129. venetian snares review music | July 22nd, 2008 at 7:33 pm

    qbhu ksjiten

  130. omaha adult lifestyle swing | July 22nd, 2008 at 8:02 pm

    frkhi

  131. free1663 | July 23rd, 2008 at 1:20 am

    ibpujql

  132. free970 | July 23rd, 2008 at 3:31 am

    cvdejx encsvz

  133. free7594 | July 23rd, 2008 at 8:40 am

    rvigap mrgit drtaqip vztsi

  134. of5582 | July 24th, 2008 at 5:25 am

    ofzxb wjxga fmkd

  135. of768 | July 24th, 2008 at 9:10 am

    jpqb udrt

  136. free1021 | July 24th, 2008 at 11:43 am

    ahpm

Leave a Comment