LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-04-2003, 06:42 AM   #1
ForumKid
Member
 
Registered: Dec 2001
Posts: 195

Rep: Reputation: 30
Accidentally cleared the password file


OK..Made a big mistake. I accidentally cleared the password file. Cant sign on as root cause it says no such user. I realized what I did so I created a quick account. But the account has no priveledges. How can I recreate the entries in the password file so I can regain control of this redhat box? Im sure there is a way, but I havent the foggiest idea...

Thanks in advance as always
 
Old 03-04-2003, 06:48 AM   #2
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
If it boots up with LILO, when it says "boot:", type in "linux single", or single after whatever your normal title is.

If it boots up with GRUB, select the linux entry, and type "e" to edit. Select the line that starts with "kernel", and type "e", again. At the end of the line, add a space and "single". Hit [enter] to get back to the main GRUB menu, and type "b" to boot.

This will boot you into single-user mode. It's a runlevel for root to do system maintenance. It is one user / no network, and doesn't need a password, for just such emergencies. When it's in runlevel one, you can passwd username for your accounts.

If you use GRUB, you might have to re-edit as above to remove the "single" to boot to your normal runlevel.
 
Old 03-04-2003, 06:51 AM   #3
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Boot from INSTALL DISK #1, type in 'linux rescue' and mount your root filesystem. See if you have a passwd.OLD in your system. If you do, you can copy it to /etc/passwd. If not, create a simple entry in /etc/passwd for root so you can boot your system and login. I'm assuming you're using shadow passwords and that your /etc/shadow is intact. Please update your profile with the distro you're using.

root:x:0:0:root:/root:/bin/bash
 
Old 03-04-2003, 06:57 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
booting into single mode will not help the situation, as the password file no longer exists, and so neither do a whole bunch of system users etc...

you might be able to get away with trying to re-write it, but it's a hell of a chore, seeing as an average system will have 40 or so system users (for mail daemons, rpm etc...)
 
Old 03-04-2003, 06:59 AM   #5
ForumKid
Member
 
Registered: Dec 2001
Posts: 195

Original Poster
Rep: Reputation: 30
Hi,

Thanks for all the advice..I have two exact same boxes. Can I copy the password file from the server thats not messed up and copy to the messed up server. I think I can, but will not have the authority on the messed up server.....
 
Old 03-04-2003, 02:53 PM   #6
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Sure you can. If you're sure they have almost identical setups. By doing so, you will replicate the users you have on your _good_ server. I would suggest syncing up /etc/shadow too, just so there wont be users without passwords or vice-versa. That will replicate the user passwords too. If you intend to change the user passwords, you may do so by logging in as root.. preferably in single user mode so as to keep other people away during those few minutes.
 
Old 03-04-2003, 02:57 PM   #7
ForumKid
Member
 
Registered: Dec 2001
Posts: 195

Original Poster
Rep: Reputation: 30
OK thanks so much once again. One last question. Will I have the authority to do the copy? Im just trying to cover all ends before I do this. Im assuming single user mode will allow me to access the box with root access even though there is no password.

Thanks for the information on the shadow file. ill copy that one too.....

Thanks
 
Old 03-04-2003, 03:37 PM   #8
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
>Will I have the authority to do the copy? Im just trying to cover all ends before I do this. Im assuming single user mode will allow me to access the box with root access even though there is no password.

Nope, single user mode assumes that there is a /etc/passwd and that there is a root entry in it. As I'd suggested in an earlier post, you'll have to boot into linux from a rescue-cd or similar, mount your root filesystem, copy the files from a floppy or similar ( assuming that you have the files needed copied to the floppy from the good server). Unlike single user mode, the rescue mode uses a _different_ root filesystem and hence looks up a different /etc/passwd to log you in and do your stuff.
 
Old 03-04-2003, 04:01 PM   #9
WeNdeL
Member
 
Registered: Oct 2002
Location: At my desk...
Distribution: RedHat, Fedora, Ubuntu
Posts: 344

Rep: Reputation: 30
doh...

way to help the man...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cleared mbr nrayever Linux - General 1 11-29-2005 11:02 PM
depmod got cleared out? slinky2004 Linux - General 1 10-10-2005 11:58 PM
accidentally del /etc/group file in RedHat 9 karmakid Linux - Security 3 08-02-2005 08:16 PM
Help needed to recover data from ext3 file system where mkfs was issued accidentally kapilsampath Linux - General 4 04-26-2005 07:52 AM
I accidentally deleted make file in /usr/local/bin, now cannot use make command.... Niceman2005 Linux - Software 2 11-17-2004 07:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:27 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
Open Source Consulting | Domain Registration