used "rm -rf / " by some mistake... how to rollback now ?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
2) when i do rm -rf / what all files, users, daemons get deleted ? AND HOW TO ROLLBACK THIS ALL ?
Everything on the machine gets deleted. There is no real roll back for this deletion. You may be able to recover the system using Testdisk, but I assume that you have not immediately powered down the machine, so that writes to the disk did already happen. In this case it is unlikely to recover the system to a known good state.
So your fastest and best options to recover are:
- restore your backup. If you don't have one now you know why you should make backups.
- install from scratch
Just a tip when you get up and running. I have a healthy paranoid with dangerous commands such as rm -rf or dd.
I type the command without the sudo in front of it. I then go back to the beginning of the line and add sudo after verifying it's correct. It probably sounds like extra pointless work, but I've never accidently deleted my root partition either
Just a tip when you get up and running. I have a healthy paranoid with dangerous commands such as rm -rf or dd.
I type the command without the sudo in front of it. I then go back to the beginning of the line and add sudo after verifying it's correct. It probably sounds like extra pointless work, but I've never accidently deleted my root partition either
Not a bad Idea. you could always use the -I or -i option as well. If heard where somepeople create shortcuts in there bash files where anytime they use rm it adds the -I or -i Option.
Either way it all comes down to paying attention and understand and verify what you do before you do it. As some actions are not reversible.
I reinstalled my first UNIX system because I did an fsck on a partition... unfortunately it happened to be the diagnostic partition that spanned the entire drive. And wiped out every file on all partitions.
I had a C program once, running as root, where I passed a pointer to a proc and that pointer was supposed to be pointing to a PID that the proc would then kill. This was a long time ago, SystemV I believe, and back in those days you could read the null pointer (I beleve most/all OS'es now-a-days balk at this). But back then it was a legal, albeit stupid, thing to do. Anyway, upon debug after-the-fact, I learned that my null pointer apparently (and umfortunately!) was pointing to "1" when I passed it to that proc.
It was a very ungraceful, but lightening quick, system shutdown! Believe it or not, the system came right back up after that (I believe an fsck may have been involved though).
I know I've done it. It was back in the RedHat 7 days (2000/2001) when I was first learning Linux. I THOUGHT that I was in a useless directory in root's home, and ran an "rm -fr *". Turns out I was actually in /. I Ctrl+C'd as soon as I realized it, but it was too late. After about 6 hours of trying to fix the system, I threw in the towel and reinstalled the OS.
OP - I hate to say it, but this is one of those mistakes that you rarely come back from. I bet you'll never do it again though!
Last edited by suicidaleggroll; 01-22-2013 at 05:23 PM.
As per above post
Even at work, if you're a SysAdmin and never wiped out a major dir, you're not working hard enough.
I bet you do proper backups from now on though ...
Once I was trying to wipe my MBR with dd. I wasn't thinking and set the count to 512 bytes instead if 446, wiping out my partition table.
I had something similar with an USB flash drive. I wanted to write an image to it using dd, unfortunately I wrote the image to the harddisk of my work PC. Luckily, my boss just laughed and I had to re-install the machine, this time making a proper backup.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.