Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I recover /etc/passwd?

Status
Not open for further replies.

debpandra

MIS
Oct 8, 2002
1
US
hello,
by mistake I deleted all the content of the /etc/passwd. I have red hat 7.2. It uses the /etc/shadow file. I don't know if this could help. Next time I will do a backup of the /etc/passwd file, but now, is there any way to recover the content of that file? i didnt restart the computer yet.

thanks a lot for your reply
Deb





 
You are going to have one hell of a time.
I would boot from a floppy(single user will not do it)
and search /etc for a backup copy first, many times when /etc/passwd is edited a responsible editing program will make a backup.
If this is the case it's a nobrainer to restore.

Otherwise you will have to copy accountnames from shadow
(or find/write a utility that does this) and restore the user accounts to a new passwd file, and then manually
restore the passwd info for each.

Good Luck
 
Look into using John the Ripper, it has a password conversion utility to take shadow passwords and make a new /etc/passwd file. Maybe it can write a new /etc/passwd, and then you can convert back to shadow passwords. Actually, on RH, try the tool 'authconfig', and that will turn off shadow passwords and write a new /etc/password (I think). HTH
 
Cut the usernames from /etc/shadow and insert them into a new /etc/passwd...

cut -d: -f1 /etc/shadow > /etc/passwd

Get yourself a copy of another Red Hat 7.2 /etc/passwd file and copy over the default users to your new file.

Fill in the rest of the fields for the users that you created. Start numbering the UIDs and GIDs with 500.


ChrisP
 
There should be a backup of a recent passwd file stored as /etc/passwd- Cheers

man(1) is your friend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top