LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   somehow did "rm -rf /*" and restored it BUT .. (http://www.linuxquestions.org/questions/linux-newbie-8/somehow-did-rm-rf-%2A-and-restored-it-but-4175428225/)

isourabh.wadhwa 09-20-2012 10:53 AM

somehow did "rm -rf /*" and restored it BUT ..
 
I accidentaly did

Code:

rm -rf /*
but cancelled it in 7 or 8 seconds .. after that i tried ls command but no use, /bin was gone .. cd was working .. I restored it through TSM(Tivoli storage manager) ..

now /bin is back .. i am able to make new sessions with server which i was not able to after "rm" command .. now I am not sure what else got deleted from this server .. is there any way to get a list of recently deleted files so I could restore these files ?

Celyr 09-20-2012 10:57 AM

if /boot is untouched then only /bin is affected when you issue rm -rf /* it will delete your files in alphabetical order.
if /boot doesn't not exist then /dev is the next, then /etc, /home and so on.
But if /boot is still there you are lucky and I'm not sure you deserve it :D

isourabh.wadhwa 09-20-2012 11:02 AM

Quote:

Originally Posted by Celyr (Post 4785133)
if /boot is untouched then only /bin is affected when you issue rm -rf /* it will delete your files in alphabetical order.
if /boot doesn't not exist then /dev is the next, then /etc, /home and so on.
But if /boot is still there you are lucky and I'm not sure you deserve it :D

yeah, you're right, I dont deserve it .. and now my emotions >> Oh cr*p .. /boot is empty .. I am starting restore right now .. I guess I can scp /boot from similar linux server

am I right ?

isourabh.wadhwa 09-20-2012 11:03 AM

Thank god .. I have backup of /boot too. I'll restore it :D ..

Celyr 09-20-2012 11:07 AM

If dev is empty it's not a problem, a reboot should fix it.
But look at etc before. Anyway if /boot is still there it shouldn't have deleted anything in /dev

szboardstretcher 09-20-2012 11:16 AM

I would suggest using a regular user, instead of root -- in the future.

Also, if you are extremely paranoid, as you should be as a system-admin, you can always make a small function that looks for 'rm -rf /' being executed and warns you, or just completely disallows you -- so you have to go through several hoops to make a mistake like that.

isourabh.wadhwa 09-20-2012 11:23 AM

Quote:

Originally Posted by Celyr (Post 4785144)
If dev is empty it's not a problem, a reboot should fix it.
But look at etc before. Anyway if /boot is still there it shouldn't have deleted anything in /dev

/boot was emty but the directory itself was there .. I just did a restore and everything is back.

Fortunately, I handle both backup and Linux. :D ..

isourabh.wadhwa 09-20-2012 11:25 AM

Quote:

Originally Posted by szboardstretcher (Post 4785151)
I would suggest using a regular user, instead of root -- in the future.

Also, if you are extremely paranoid, as you should be as a system-admin, you can always make a small function that looks for 'rm -rf /' being executed and warns you, or just completely disallows you -- so you have to go through several hoops to make a mistake like that.

yeah true .. I guess tha would be best ..my intention was to delete all contents of my home directory on which some files had root permissions .. so i did
Code:

sudo rm -rf /*
instead of
Code:

sudo rm -rf ./*

yes .. I forgot the dot or i pressed it very lightly on the keyboard ..

Celyr 09-20-2012 11:39 AM

Well, IMHO the real issue here is -rf, I've used to use those flags a lot as well and they are evil -f flag is evil, -r is pretty evil and all together are super evil. I've lost the habit of using them.
Also aliasing rm to rm -I is a good idea

suicidaleggroll 09-20-2012 11:49 AM

I don't think there's a single experienced Linux admin here who hasn't done something similar when they were first starting out. Usually it results in a format and re-install of the OS, but since you had backups you may be able to recover. There's no better way to learn caution when using rm than accidentally doing something like this though.

Celyr 09-20-2012 11:56 AM

ok, to be honest i did
Code:

rm -rf ~* instead of *~
and thus got delete /my/home/* instead of those damn .c~ files LOL

linux_BSD 09-20-2012 04:31 PM

I once did a rm -rf / on a linux install a long time ago in 2005. The difference is I did this on purpose to see what would happen. I was going to install another distro anyways.

When I ran rm -rf / it last until rm was no longer available i.e the bin directory was wipe out and rm no longer exited to continue the rest of the deletion.

Celyr 09-21-2012 04:18 AM

Are you sure of this behavior? I think it should go on

isourabh.wadhwa 09-21-2012 07:23 AM

Quote:

Originally Posted by linux_BSD (Post 4785366)
I once did a rm -rf / on a linux install a long time ago in 2005. The difference is I did this on purpose to see what would happen. I was going to install another distro anyways.

When I ran rm -rf / it last until rm was no longer available i.e the bin directory was wipe out and rm no longer exited to continue the rest of the deletion.

No sir, it will continue deleting .. I made a new virtual machine at home just to see what happens and it never stops.

I dont know what was hte condition in 2005, but in 2012 rm will flat every directory's ass.

segmentation_fault 09-21-2012 08:11 AM

Maybe it depends if it's dynamically linked or compiled with static libs.


All times are GMT -5. The time now is 07:48 AM.