LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-22-2013, 02:19 AM   #1
Somnath05
LQ Newbie
 
Registered: Jan 2013
Posts: 1

Rep: Reputation: Disabled
Question 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 ?
 
Old 01-22-2013, 02:38 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,380

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Just restore from your backup.
 
Old 01-22-2013, 05:05 AM   #3
tsester
Member
 
Registered: Dec 2011
Distribution: Arch linux
Posts: 44

Rep: Reputation: 2
you can see the deleted files with testdisk, though if you want to recover files, try not to write to the disk
 
Old 01-22-2013, 07:09 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Quote:
Originally Posted by Somnath05 View Post
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
 
Old 01-22-2013, 07:38 AM   #5
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Your best bet at this point is a fresh reinstall. So I hope you have a vps for easy reinstall or the server is local to you.
 
1 members found this post helpful.
Old 01-22-2013, 10:25 AM   #6
mreff555
Member
 
Registered: Sep 2011
Location: Philly
Distribution: Gentoo
Posts: 470

Rep: Reputation: Disabled
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
 
Old 01-22-2013, 11:14 AM   #7
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by mreff555 View Post
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.

Last edited by jmc1987; 01-22-2013 at 08:38 PM.
 
Old 01-22-2013, 04:56 PM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
And don't worry too much about it.

Everybody does something like this at least once.

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.
 
Old 01-22-2013, 05:47 PM   #9
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,158
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Quote:
Originally Posted by jpollard View Post
And don't worry too much about it.

Everybody does something like this at least once....
Practically a Right-of-Passage.
 
Old 01-22-2013, 06:10 PM   #10
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,114

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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).
 
Old 01-22-2013, 06:16 PM   #11
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by jpollard View Post
And don't worry too much about it.

Everybody does something like this at least once.
Quote:
Originally Posted by Habitual View Post
Practically a Right-of-Passage.
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 06:23 PM.
 
Old 01-22-2013, 06:42 PM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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 ...
 
Old 01-24-2013, 04:31 PM   #13
mreff555
Member
 
Registered: Sep 2011
Location: Philly
Distribution: Gentoo
Posts: 470

Rep: Reputation: Disabled
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.
 
Old 01-24-2013, 05:48 PM   #14
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Quote:
Originally Posted by mreff555 View Post
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.
 
Old 01-25-2013, 12:06 AM   #15
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,817

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
typos happen
back up data

after a few years you start to make less of the normal everyday " stupid human errors ", BUT they still happen .
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "Oops" termcap mistake ewsmith Slackware 2 02-24-2011 12:03 PM
Didn't install "expect-5.43" by mistake - how big a problem is it? drut Linux From Scratch 2 05-05-2008 09:00 AM
up2date "rollback" method? Atnor Red Hat 2 02-26-2008 09:28 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 09:31 AM
Recovering ext3 from mistake "mkfs" chris_haragan Linux - General 2 09-05-2005 05:58 PM


All times are GMT -5. The time now is 05:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration