5 ms·
The reason we all know to be careful with rm -r is because of that one time we weren't. Me, it was the time I rm r'ed the MySQL data directory for my company's
by crikli 15y ago
The reason we all know to be careful with rm -r is because of that one time we weren't.
Me, it was the time I rm r'ed the MySQL data directory for my company's customer service management system. Oops. Thankfully we had a backup from the month prior, but I learned two things that day: a) be really careful with rm and b) take it on yourself to make sure IT is backing up stuff that you're messing with.
You gotta hedge against your own stupid.
What about you, how'd you learn the hard way?
- nl 15y agoIn a script: sudo chown -R username:group $WEBAPP For various reasons, $WEBAPP got set to "/ usr/local/blah/blah" (note the space) I had the Linode backup service, so got away with restoring the whole VM from the previous night's backup.
- illumin8 15y agoWas asked to uninstall IBM/Rational ClearCase from our source code repository server. Apparently at the time, Clearcase's installer NFS mounted 127.0.0.1:/ to a subdirectory. Don't ask me what brain-dead system designer thought this was a good idea. So, I did a simple /etc/init.d/clearcase stop (not sure that is the exact name) and: # rm -rf /opt/clearcase (hmm... that seems to be taking a little too long to run) Panic - then ctrl-C - it was too late, /opt/clearcase/foo was NFS mounted 127.0.0.1:/ and it had already trashed /bin, /sbin, /etc, /var, and most of /usr. Luckily I had good backups, but we did spend the rest of the day rebuilding the source repository while the developers couldn't check in any code.
- CGamesPlay 15y agoI've also done this, but it was a cPanel server and the jailshell did bind mounts to various directories on the system. I tried to remove the jailshell instance, and ended up removing a whole lot more.
- endgame 15y agoNot useful in your case, but I've made a habit of using rmdir when removing directories that I think might be mounted.
- mst 15y agoOne of my first tasks after being given root access at my first n?x job at an ISP was "clear off all of the DNS stuff on $main_server since we have $dedicated_dns_server now". So I merrily started mv-ing things to a scratch directory that we could wipe in 6 months if we didn't need anything from it. Unfortunately, the zone file directory was NFS mounted from* $dedicated_dns_server. With pass root set. I think I took all of A through to K of client zones offline before we noticed. I'm just very very glad I decided to do it as an mv rather than an rm, since it meant all I needed to do was copy things back. Not that I really learned my lesson that time; it took a couple more semi-disasters before I got sufficiently paranoid to be reasonably safe as root.
- redthrowaway 15y agoToo late now, but remember to escape your asterices.
- trustfundbaby 15y agodead tired, 4am in the morning working on a client app for a huge client of theirs (I was subcontracting) was trying to remove everything inside a folder and instead of going rm -rf ./* I went rm -rf . (can't get the wildcard thingamajig to show up) It took me a second to understand why the command was taking so long to run, by the time I figured it out and killed the command, I had wiped out almost half of what was on the drive. Biggest "oh. my. god" moment of my life. I think I had an actual panic attack for a bit even. Luckily, media temple had a backup from just a few hours earlier (I was lucky, they only ran them periodically and it just so happened to fall on that day).
- tta 15y agoWouldn't that just delete the folder instead of emptying it?
- delinka 15y agoBack in the day, rm followed .. if you specified it on the command line. It went like this: You are in .; The current directory listing include ..; Recursively deleting everything deletes everything on the drive. Actually, I think the one time I saw someone do this, wildcards were involved. And I was going to explain, but the comment system is making my asterisks into bold markers.
- trustfundbaby 15y agoI can't get the wildcard character to show up ... it should be x.x
- deleted 15y ago[deleted]
- sesqu 15y agoYou can prepend two spaces to insert <code> (http://news.ycombinator.com/formatdoc http://news.ycombinator.com/formatdoc): rm -rf ./* rm -rf *.* To stay on topic, because of this thread, I just added alias rm="rm -I" to .bashrc, and I have never yet needed -f.
- MatthewPhillips 15y agoMore than once I've made the mistake of running an UPDATE and forgetting the WHERE clause.
- rimantas 15y agoIn case you are using MySQL this can be handy: http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options.html#option_mysql_safe-updates http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options...