Operating System - HP-UX
1825576 Members
2065 Online
109682 Solutions
New Discussion

Merge user accounts and passwd file

 
SOLVED
Go to solution

Merge user accounts and passwd file

Hi, I am merging two L2000 onto an RP5430. I have to merge two sets of users and two passwd files. Some of the users are on both servers. Has anyone got any idears on how I could action this
Which does not kill you only makes you stronger
3 REPLIES 3
Jean-Louis Phelix
Honored Contributor
Solution

Re: Merge user accounts and passwd file

You could simply try something like 'cat passwd1 passwd2 | uniq > passwd3', but uniq works better on sorted files which could mess you passwd file (it's better to get system logins at the beginning of the file). A more sophisticated script could do it. Whatever you choose, think about using 'pwck newfile' before overidding real password file.

#!/usr/bin/sh
PASS1=$1
PASS2=$2
NEWPASS=$3
TMP=/tmp/newpass$$
cp $PASS1 $TMP
chmod 644 $TMP
for USER in $(cut -f1 -d: $PASS2)
do
grep "$USER:" $PASS1 || grep "$USER:" $PASS2 | line >> $TMP
done
pwck $TMP
mv $TMP $NEWPASS
chmod 444 $NEWPASS

Regards.
It works for me (© Bill McNAMARA ...)
Mark Grant
Honored Contributor

Re: Merge user accounts and passwd file

I would add one thing to the above post.

You will need to make sure that users that appear on both systems have the same UID and if they don't, come up with some strategy to resolve them. You could find that a user on both machines will have a UID on one machine that conflicts with a user on the other. These issues can become quite annoying when the user is an application specific user.
Never preceed any demonstration with anything more predictive than "watch this"
Paula J Frazer-Campbell
Honored Contributor

Re: Merge user accounts and passwd file

Hi

As said you will have to be careful

diff passwd_server1 passwd_server2 will help

But if you are not looking at a great number it will be quicker and safer to create from scratch.

Paula
If you can spell SysAdmin then you is one - anon