1833788 Members
2357 Online
110063 Solutions
New Discussion

Re: NIS Automation

 
Matthew F. Carr
Occasional Advisor

NIS Automation

Greetings, I am currently implementing a NIS domain to about 80 HP-UX Servers. I was wondering if any one had a way to converting each user's UID (currently 3 digits) into a new 5 digit standard and furthermore go back to the original server it came from and updating it there to ensure proper file ownership issues.
2 REPLIES 2
Donald Kok
Respected Contributor

Re: NIS Automation

You already have it. UID are actualy not digits but a two-byte hexadecimal number. Two bytes go up to (dec) 65535, which is a digits.

There are reasons not to change the UID's of users:
- every file in your filesystems has the UID of the owner, you will have to change that for every file each user owns.
- When you need to restore from a previous backup, the 'old' UID's are on the tape, so they don't match anymore with the 'new' UID

I bet other members come up with more reasons.

That leaves you with the situation where on different systems a UID belongs to different users. This sure is a pain.
My systems are 100% Murphy Compliant. Guaranteed!!!
Shannon Petry
Honored Contributor

Re: NIS Automation

There is a command called usermod which may do what you want. It will modify any piece of the user ID, which includes permissions on the home directory recursively. (Check to ensure you dont choose a person with a home of "/")!!!!!

I.E.
set -i
UID=20001
% for NAME in `cat /etc/passwd|grep -v root|grep -v lp|awk -F: '{print $1}'` ; do
#AND FILL ALL THE OTHER NOT ROOT STUFF IN HERE THAT DONT GET MODIFIED
# AND BUILD IN TESTS SO YOU DONT KILL YOUR OS
% usermod -u $UID $NAME
% UID=`expr $UID + 1`
% done


As someone else mentioned, this brings up other issues to at least plan for. I.E. backups will require an additional step to chmod because the UID is stored on the tape, not the user name.

Regards
Shannon
Microsoft. When do you want a virus today?