LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-21-2012, 05:20 AM   #1
n_raghuvanshi
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Rep: Reputation: Disabled
Exclamation root user got deleted


Hi Everyone,

I am using SuSe Linux enterprise server 10 as a telephony server. I was doing some activity on the server. I don't know what happened, root user got deleted on the system. Now if I am trying to login through root it is saying root user does not exist. If I am trying to do "sudo" it is saying root user does not exist. Even the home directory of root(/root) is not there anymore. Can I get it back somehow, can someone help me with that.


Thanks
 
Old 03-21-2012, 06:59 AM   #2
Celyr
Member
 
Registered: Mar 2012
Location: Italy
Distribution: Slackware+Debian
Posts: 321

Rep: Reputation: 81
Hi,

have a look at /etc/passwd

you can even paste it here, there is no password there
 
Old 03-21-2012, 10:14 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by n_raghuvanshi View Post
Hi Everyone,
I am using SuSe Linux enterprise server 10 as a telephony server. I was doing some activity on the server. I don't know what happened, root user got deleted on the system. Now if I am trying to login through root it is saying root user does not exist. If I am trying to do "sudo" it is saying root user does not exist. Even the home directory of root(/root) is not there anymore. Can I get it back somehow, can someone help me with that.
Thanks
No idea, since you don't say what the "some activity" you were doing was. If you don't have a root user, you won't be able to edit secure files like /etc/passwd.

You're using Suse Enterprise...which means you're paying for support from Novell, so I'd call them. You can also boot from CD/DVD, go into rescue mode, mount your hard drive, and edit the /etc/passwd and /etc/shadow files from there, taking those lines from the files on the rescue DVD. Pay VERY close attention to file permissions, and also recreate the users /root home directory. Then try to log in again. Your only other choice is to reload the system from backups, but even that may not work...lots of things depend on the root user being there and having permissions...your backup utility may be one.
 
1 members found this post helpful.
Old 03-21-2012, 11:51 PM   #4
n_raghuvanshi
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi Guys,

Thanks for your reply.

The server is SLES10 and a telephony server application is running on it. Aastra technologies provides this whole setup. So I can not go to Novell, I will have to go to Aastra. But the server is not in production, it's a lab machine and running on trial license, so even aastra can not help me. Moreover I am sitting in Delhi, India and server is lying in Stockholm, Sweden, So I can not put a recovery DVD in it. I can only access it via ssh.
When I met with the problem, I was installing the application provided by aastra, but it got stuck. So I killed the two processes running by this application (using kill -9) and restarted the server. Guess what happened I can not find root user anymore.

/etc/passwd and /etc/shadow both files are there. I can get into passwd but not in the shadow with current user. I can see in passwd file "root" line is not there. Can I get get something by editing this file.


Thanks.
 
Old 03-22-2012, 12:35 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
May be I am missing a point, but if this is a lab machine on a testing license, not a production machine, why do you actually care? Just re-install the system (not mentioning to just restore your backup) and try it again.
 
Old 03-22-2012, 12:53 AM   #6
n_raghuvanshi
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi,

You are not getting the point. This is a Lab machine, but I can not reinstall the linux because I am not in front of the machine, it is lying in Stockholm and I am sitting in Delhi. To reinstall the machine I have to be physically available in front of the machine.

I have edited the /etc/passwd file now and added the root user line. Now If I am doing "su" it is asking for password but it is not taking the password because I can not get into the /etc/shadow and from shadow file it takes the password.

Can we do something about it. Can I edit something in passwd file so it won't ask for password anymore.

Thanks
 
Old 03-22-2012, 02:40 AM   #7
ozanbaba
Member
 
Registered: May 2003
Location: İzmir
Distribution: Slackware64 15.0 Multilib
Posts: 778

Rep: Reputation: 135Reputation: 135
Quote:
Originally Posted by TB0ne View Post
No idea, since you don't say what the "some activity" you were doing was. If you don't have a root user, you won't be able to edit secure files like /etc/passwd.

You're using Suse Enterprise...which means you're paying for support from Novell, so I'd call them. You can also boot from CD/DVD, go into rescue mode, mount your hard drive, and edit the /etc/passwd and /etc/shadow files from there, taking those lines from the files on the rescue DVD. Pay VERY close attention to file permissions, and also recreate the users /root home directory. Then try to log in again. Your only other choice is to reload the system from backups, but even that may not work...lots of things depend on the root user being there and having permissions...your backup utility may be one.
init=/bin/bash and you got your root access.
 
Old 03-22-2012, 06:02 AM   #8
centos123
Member
 
Registered: Apr 2011
Posts: 397

Rep: Reputation: 16
put in /etc/passwd file
root:x:0:0:root:/root:/bin/bash

and in /etc/group
root:x:0:root


and save it.
 
Old 03-22-2012, 06:09 AM   #9
n_raghuvanshi
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by centos123 View Post
put in /etc/passwd file
root:x:0:0:root:/root:/bin/bash

and in /etc/group
root:x:0:root


and save it.
I tried it but not working. it is saying "incorrect password". When the user got deleted password details from /etc/shadows must have got deleted at the same time. So it is not able to access the password I guess.

Any other idea!
 
Old 03-22-2012, 09:09 AM   #10
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
You need a proper line in /etc/shadow too. Either create/copy a hash value from another line therein from which you know the password (and as you can log in there it should be possible), or set it to an empty one. In the latter case it might be necessary to set in one of the PAM files to allow empty passwords:
Code:
auth	required	pam_unix2.so nullok
 
Old 03-23-2012, 12:07 AM   #11
n_raghuvanshi
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Reuti View Post
You need a proper line in /etc/shadow too. Either create/copy a hash value from another line therein from which you know the password (and as you can log in there it should be possible), or set it to an empty one. In the latter case it might be necessary to set in one of the PAM files to allow empty passwords:
Code:
auth	required	pam_unix2.so nullok
Hi

Sorry, I didn't understand. Can you elaborate it a bit. I am not an expert of Linux.
 
Old 03-23-2012, 11:08 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by n_raghuvanshi View Post
Hi
Sorry, I didn't understand. Can you elaborate it a bit. I am not an expert of Linux.
Well, we've been very clear...what don't you understand? You deleted the root user...you now have NO PERMISSIONS to edit those files. Your only choices remain:
  • Boot from CD/DVD, mount the hard drive manually and edit the files
  • Restore things from your backups
  • Reboot the system into single-user mode, and HOPE that you have root access to edit the files
Doesn't get much simpler than that. Also, above, it was suggested that you use "init=/bin/bash"...did you try that? You already KNOW you can't edit that file with the system booted. You are going to HAVE TO take other action, period. Doesn't matter where you are, or where the server is...YOU are the administrator, and it's up to YOU to make it right. You've been given the options how...it's up to you to figure out which is best for you, and make them work.
 
  


Reply



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
Can the root user be deleted by webmin? hua Slackware 10 09-10-2008 09:11 AM
[phpMYAdmin] Problem ! Help. I''ve deleted root user in MYSQL combilli Linux - Software 1 12-07-2006 01:30 PM
I deleted my root user... patdawg Linux - Newbie 18 03-29-2006 04:15 PM
Deleted user Root? legendaryfox Linux - Software 4 01-09-2005 01:12 PM
Deleted root user france Linux - Newbie 1 04-30-2004 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:47 PM.

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
Open Source Consulting | Domain Registration