LinuxQuestions.org
Visit Jeremy's Blog.
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 01-28-2010, 12:29 PM   #1
fandar
Member
 
Registered: Oct 2006
Posts: 61

Rep: Reputation: 15
Deleted /etc on centos with whm. Howto recreate passwd?


Hi, someone deleted /etc folder on server with WHM and about 100 users.
Well, I can copy the /etc from exactly the same server and change there some settings like ip address, etc. But the main problem is the passwd and shadow files. Is there some way howto recreate it from home folder?
In the home folder are still all files, the dir name under /home/* is name of user and there is also still info about uid, gid. Is there some way (some script) howto recreate the passwd file from this info and recet password to some default? Thank You
 
Old 01-28-2010, 12:41 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Yes, you could write a script to loop through a list of the folders in /home and add a user with the same name & ID, then set it a password.
 
Old 01-28-2010, 12:42 PM   #3
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
If that's honestly the only difference, which I find *VERY* hard to believe then yes you can script something to add a username after the name of the home directories. I'd take a copy of passwd group and shadow from a similar server too, and then just add them as if they were normal users.

Personally I'd probably not write a loop or anything, but do an "ls -l /home" and mangle the output to form a number of lines directly.

ls -l /home | awk '{print "useradd -u $2 -g $3 $9"}'

and then run the output if you're happy with it.
 
  


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
[SOLVED] Deleted testuser from passwd file but squid still allows connections qwertyjjj Linux - Server 2 08-15-2009 11:46 AM
unexpected reboot - linux server - centos 5.1 - cPanel / WHM GiotisSL Linux - Server 1 03-28-2008 05:42 PM
Apache won't start - missing SSL certificates, howto recreate them? GoBillsBN Linux - Networking 3 01-31-2007 06:22 PM
Howto change system password policies (passwd length, complexity) tisource Linux - Security 3 09-06-2005 12:01 AM
jabber+/etc/passwd any howto? pudhiyavan Linux - Networking 0 03-12-2004 10:08 PM

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

All times are GMT -5. The time now is 11:12 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