LinuxQuestions.org
Help answer threads with 0 replies.
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-07-2007, 04:13 PM   #1
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Rep: Reputation: 30
Deleted root account - Ubuntu 6.06


I can't beleive I just deleted the root account. SO I try to get it back:
Code:
[05:04:49][dv5000t>~]$ useradd root
useradd: unable to lock password file
[05:05:04][dv5000t>~]$ sudo useradd root
sudo: no passwd entry for root!
Now I'm just thinking, ohh no. I can't do sudo commands anymore, so I can't add the user root back!
 
Old 01-07-2007, 04:34 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
Boot from Ubuntu CD. Mount your installed system. Run 'chroot /mnt/installed' (or whatever it is called). Run 'man useradd', read the key name to set uid to 0 (or everything will be more difficult; if you still make a mistake - usermod will help), and run useradd with needed options.
 
Old 01-07-2007, 04:47 PM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Check if you are missing entries for root in /etc/passwd and /etc/shadow.

Adding these lines may help if they aren't present. Edit the files offline using a rescue disk or live distro. Then if you can reboot, into single mode, make sure you run "passwd" to give the root user a password.

/etc/password
root:x:0:0:root:/root:/bin/bash

/etc/shadow
root::13289::::::
 
Old 01-07-2007, 05:38 PM   #4
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
You did not delete the root account. Its still there, but on Ubuntu, the root account is locked i.e. has no password. Just do "sudo passwd root" to give root a password and you should be able to login to the root account.
 
Old 01-07-2007, 05:53 PM   #5
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by reddazz
You did not delete the root account. Its still there, but on Ubuntu, the root account is locked i.e. has no password. Just do "sudo passwd root" to give root a password and you should be able to login to the root account.
Code:
[06:42:19][dv5000t>~]$ sudo passwd root
sudo: no passwd entry for root!
Quote:
Check if you are missing entries for root in /etc/passwd and /etc/shadow.

Adding these lines may help if they aren't present. Edit the files offline using a rescue disk or live distro. Then if you can reboot, into single mode, make sure you run "passwd" to give the root user a password.

/etc/password
root:x:0:0:root:/root:/bin/bash

/etc/shadow
root::13289::::::
Too bad cdrecord requires root privlages.
 
Old 01-08-2007, 02:20 AM   #6
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
Wait, do I need a rescue cd, or a live cd?
 
Old 01-08-2007, 02:40 AM   #7
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
You need any CD that gives you shell. Rescue CD or Live CD - no matter.
 
Old 01-08-2007, 04:58 PM   #8
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
This is why I asked the previous question. I booted from the ubuntu live cd, (on the install cd there is a livve cd of ubuntu too), and I opened up a terminal, opened up /etc/passwd, and it was nothing like the file that I have when I don't use a live cd.

I will try a slackware install cd I have lying around, and say how that goes.
 
Old 01-08-2007, 05:00 PM   #9
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,893

Rep: Reputation: 68
Did you open LiveCD /etc/passwd or your system's /etc/passwd (to view the latter you need to mount your system first)?
 
Old 01-08-2007, 05:43 PM   #10
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
Code:
ubuntu@ubuntu:~$ mount /dev/sda3
mount: can't find /dev/sda3 in /etc/fstab or /etc/mtab
/dev/sda3 was my partion for /, and since I'm not in /dev/sda3, I won't be able to acess /dev/sda3.

I'm so stupid for doing this.

edit:
Whats wrong with just editing the file while I am not in a live cd?

Last edited by User Name.; 01-08-2007 at 05:48 PM.
 
Old 01-08-2007, 05:58 PM   #11
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
Code:
mkdir /mnt/sda3
mount /dev/sda3 /mnt/sda3
Mounting doesn't need fstab, it's just to mount things automatically (most importantly, at boot).

Quote:
Whats wrong with just editing the file while I am not in a live cd?
I can't see a problem with it, but I'm a n00b.

Last edited by Ynot Irucrem; 01-08-2007 at 05:59 PM.
 
Old 01-08-2007, 06:35 PM   #12
User Name.
Member
 
Registered: Aug 2006
Distribution: Ubuntu 8.04
Posts: 178

Original Poster
Rep: Reputation: 30
Thanks, I don't know why I didn't think of that.
 
Old 01-09-2007, 12:36 AM   #13
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
I thought that you couldn't use sudo anymore. You can only edit /etc/password as root. In the live distro, mount your old root partition somewhere. You said it was /dev/hda3.

If you are using the ext3 filesystem then
mount -t ext3 /dev/hda3 /mnt/
will mount it under /mnt.

If you are using a rescue disk, it may not have vim but instead vim-minimal.
You need to check if the root entries exist in /etc/passwd and /etc/shadow.
 
  


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
Deleted ROOT account Ashrack Linux - General 1 09-17-2006 12:13 PM
Identifying non-administrators w/ root privilege/ Multiple root account in use wjeanpaul Linux - Security 4 05-19-2006 08:55 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
MySQL deleted root account and can't re-install... ivj Linux - Software 2 07-09-2004 10:51 PM
root account Deleted chandu Linux - Security 1 06-18-2004 12:47 PM


All times are GMT -5. The time now is 04:56 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration