Linux Users

cancel
Showing results for 
Search instead for 
Did you mean: 

used "rm -rf / " by some mistake... how to rollback now ?

Hi All,

               this is very urgent.

i logged in my RHEL linux machine via PUTTY .as say XYZ user.

then  i

typed followinfg command

sudo su -

and then i put password for XYZ user.

then

inside home directory i created directory say test_directory1. and inside test_directory1 another directory say "new_testdirectory" is created.

then i disconnected from PUTTY.

then i again login via PUTTY as XZY again

and again typed sudo su -

and this time i first navigate to test_directory1

when i put command here :   ls

it showed me "new_directory" as result.

now here i did one mistake.. I WANTED TO DELETE THIS "new_directory" so i should type following command

rm -rf new_direcotory /

BUT

MISTAKE I DID IS

rm -rf /

this / made difference..

now problem is via PUTTY when i login it is now allowing me to login as XYZ user...

so i found out the way to login by coping bin folder from another RHEL machine to my this RHEL machine... so now i can login via PUTTY.

BUT NOT ABLE TO DO "sudo su - "

MY QUESTION IS

1) how to FIX THIS sudo su - login problem

2) when i do rm -rf / what all files, users, daemons get deleted ? AND HOW TO ROLLBACK THIS ALL ?

0 Kudos
Message 1 of 5
(11,614 Views)

Hi!

Quoting from Wikipedia (http://en.wikipedia.org/wiki/Rm_%28Unix%29)

rm -rf (variously, rm -rf /, rm -rf *, and others) is frequently used in jokes and anecdotes about Unix disasters. The rm -rf variant of the command, if run by a superuser on the root directory, would cause the contents of nearly every writable mounted filesystem on the computer to be deleted, up to the point the system itself crashes from missing some crucial file, directory, or the like.

So, if you did what you said you did, I think you should consider to reinstall your system.

Regards,

Marco

0 Kudos
Message 2 of 5
(5,614 Views)

Marco is right. Unless you were doing backups of the machine, there is not a way to roll back the rm -rf /. It is amazing that you are able to log in at all.

As part of the recovery process you might use a Linux LiveCD such as Recovery Is Possible (RIP).

http://www.tux.org/pub/people/kent-robotti/looplinux/rip/

This will allow you a number of ways to move any data that needs to be saved to another machine before reinstalling or reimaging the damaged one.

0 Kudos
Message 3 of 5
(5,614 Views)

A tough way to learn the lesson that you should always be a little nervous when you see that # at the end of your command line where your $ belongs. Avoid becoming root unless you really, really need to be: use sudo <cmd> when you need admin privileges for a specific command and otherwise just su to the relevant (non-privileged) user when you have to deal with their files.

Someday, when you have data again, you can implement a remote or local backup (fairly) easily using duply and/or duplicity. This can be set up to store the backups on Amazon S3 for little or no cost:

Mario

0 Kudos
Message 4 of 5
(5,614 Views)

Also this is a weird place (National Instruments-specific forum) to ask this question (generic/entry-level Linux).

In the future:

0 Kudos
Message 5 of 5
(5,614 Views)