LinuxQuestions.org
Register a domain and help support LQ
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 12-23-2011, 01:44 PM   #1
BradMarks
LQ Newbie
 
Registered: Jul 2011
Location: Los Angeles, CA
Distribution: rhel6
Posts: 26

Rep: Reputation: Disabled
Question Moving from HP-UX to RHEL6 - /etc/passwd


Hi,
I've searched and not found anything like this.
I have more than 1,000 users in my HP-UX /etc/passwd file. Are there any means of moving usernames and passwords to my new Red Hat box? My concern is the UID; I think the rest of the HP-UX entry could be utilized.
Thanks,
Brad
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 12-23-2011, 01:57 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Suggestion -

If you really have 1000+ users (or even 20+ users), then why not use a directory service (instead of /etc/passwd)? If your organization already has a directory service, this might be a great time to integrate it with Red Hat.

Plan B would be to write a simple shell script that:

1. Parses your old /etc/passwd (in a loop)

2. Adds all needed groups first

3. Does the appropriate "useradd" for each user (including hard-coded UID, if it's important to you)

Last edited by paulsm4; 12-23-2011 at 01:58 PM.
 
Old 12-23-2011, 02:04 PM   #3
BradMarks
LQ Newbie
 
Registered: Jul 2011
Location: Los Angeles, CA
Distribution: rhel6
Posts: 26

Original Poster
Rep: Reputation: Disabled
Thanks, Paul, I appreciate your response.

Unfortunately this is a legacy system from the 80's, and for reasons particular to the language we run under Linux, using a directory service is not appropriate.

Meanwhile, what about the user ID? Do they simply have to be unique within passwd, or is there a dependency in some other OS file/database?

Regards,
Brad
 
Old 12-23-2011, 02:07 PM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hello Brad,

First create tar ball of old users in your old system.

Create a directory:

Quote:
# mkdir /root/move/
Setup UID filter limit:

Quote:
# export UGIDLIMIT=500
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e., only copy user accounts):

Quote:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig
Similarly you can create .mig files of /etc/group, /etc/shadow also.

Now you should also create backup of /home and /var/spool/mail dirs:

Quote:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail


Now on new Linux machine, first, make a backup of current users and passwords:

Quote:
# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak
Now restore passwd and other files in /etc/

Quote:
# cd /path/to/location...
# cat passwd.mig >> /etc/passwd

Now copy and extract home.tar.gz to new server /home :

Quote:
# cd /
# tar -zxvf /path/to/location/home.tar.gz
Similarly for /var/spool/mail directory also.

And at last now reboot the new machine.


Hope it should work for you and let us know the results...
 
2 members found this post helpful.
Old 12-23-2011, 02:13 PM   #5
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Now as per your UID's concern, in RHEL default is 500 and upper limit is 65534 and check /etc/libuser.conf file for UID values.

And in Debian and Ubuntu, default is 1000 and upper limit is 29999.
 
Old 12-23-2011, 03:22 PM   #6
BradMarks
LQ Newbie
 
Registered: Jul 2011
Location: Los Angeles, CA
Distribution: rhel6
Posts: 26

Original Poster
Rep: Reputation: Disabled
Thumbs up Wow!

Satyaveer,
Incredibly helpful. Many thanks.
My HP-UX system is so old, the user ID #s are all over the place (from 108 to 1295!). Not 500 and up like in Linux. The nice thing is that all users belong to a single group # so I can parse them out by tweaking the instructions you supplied.
Then, once on the new system, I will write a script that will re-assign UIDs starting at 510 (we already created 9 new users) and increment after each change.

It will probably be a while, but I will definitely let you know how it goes.

Thank you,
Brad
 
Old 12-25-2011, 01:04 PM   #7
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hello Brad,

Well, thanks thanks for appreciating. Now, if your problem has been solved then you can mark your thread as solved and if you find post helpful you can give your feedback and reputation.
 
  


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
Moving /etc/passwd and /etc/shadow in a read-only system Red Hat 6 redrat Linux - Software 56 09-22-2011 06:26 PM
Moving user accounts between computers (Something wrong with passwd, shadow, etc.) Lionhard Linux - Software 5 01-18-2008 09:53 PM
Moving portions of /etc/passwd and /etc/shadow skreaminskull Linux - Security 3 05-19-2006 11:35 AM
Moving passwd file to new server rtcary Linux - Newbie 5 07-20-2005 02:58 AM
Moving /etc/passwd and /etc/shadow john8675309 Linux - Software 1 01-24-2005 09:44 PM


All times are GMT -5. The time now is 04:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration