LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Moving from HP-UX to RHEL6 - /etc/passwd (https://www.linuxquestions.org/questions/linux-newbie-8/moving-from-hp-ux-to-rhel6-etc-passwd-920226/)

BradMarks 12-23-2011 12:44 PM

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

paulsm4 12-23-2011 12:57 PM

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)

BradMarks 12-23-2011 01:04 PM

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

Satyaveer Arya 12-23-2011 01:07 PM

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...

Satyaveer Arya 12-23-2011 01:13 PM

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.

BradMarks 12-23-2011 02:22 PM

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

Satyaveer Arya 12-25-2011 12:04 PM

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.


All times are GMT -5. The time now is 08:36 AM.