Operating System - HP-UX
1833589 Members
3976 Online
110061 Solutions
New Discussion

i need to change some UIDs

 
SOLVED
Go to solution
Mark Harshman_1
Regular Advisor

i need to change some UIDs

just doing a sanity check. I need to change some UID's in order to get them in sync on different systems. If i do this thru sam, anything i need to be concerned with? Will any file ownerships they own change as needed? this is on a server running HPUX 11i. thanks
Never underestimate the power of stupid people in large groups
9 REPLIES 9
Pete Randall
Outstanding Contributor

Re: i need to change some UIDs

Mark,

As I recall from doing this myself years ago, you'll need to modify the files' ownership after changing the UID. I would bypass SAM and do this directly in the passwd file.


Pete

Pete
Jeff_Traigle
Honored Contributor

Re: i need to change some UIDs

Or simply use the usermod command. I don't recall if it changes the UID ownership automatically or not. If it does, it would only do it on the home directory files. Anything outside the home directory will need to be found and changed manually regardless how you make the UID change.

usermod -u username
--
Jeff Traigle
Steven E. Protter
Exalted Contributor
Solution

Re: i need to change some UIDs

Shalom Mark,

I advise not using sam.

Use vipw

It edits /etc/passwd directly.

The system actually stores file ownerhip information by numeric UID, so you will want to look at the some files owned by this user.

You may need to do a chown -R username:group to recursively change the users files.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: i need to change some UIDs

Hi Mark:

You can simply 'vipw' (or otherwise programatically edit) the ''etc/passwd' file if this is an untrusted, non-NIS system.

The advantage to using 'vipw' is that you have some locking and under-the-covers protection of your edits.

When done, do:

# find / -user -exec chown : {} \;

...to reassign your file ownerships.

Regards!

...JRF...

Patrick Wallek
Honored Contributor

Re: i need to change some UIDs

If this is a trusted system, you will need to change the UID value in the file in the /tcb/files/auth/[a-z]/username file as well as the /etc/passwd file.

Jeff_Traigle
Honored Contributor

Re: i need to change some UIDs

Another reason to like usermod... it takes care of the TCB database automatically, if necessary. It also won't allow duplicate UIDs without the -o option so it's a good check to be sure you don't end up with duplicates with changes you attempt to make... something that is not always easy to do manually when you start dealing with decent size passwd files.
--
Jeff Traigle
Mark Harshman_1
Regular Advisor

Re: i need to change some UIDs

thanks to all
Never underestimate the power of stupid people in large groups
Prashant Zanwar_4
Respected Contributor

Re: i need to change some UIDs

egrep "uid1|uid2|uid3" /etc/passwd | awk -F: '{print $1, $6}' | while read user home
do
chmod -u {value} $user
chown -Rh $user $home
done
"Intellect distinguishes between the possible and the impossible; reason distinguishes between the sensible and the senseless. Even the possible can be senseless."
Tiziano Contorno _
Valued Contributor

Re: i need to change some UIDs

Mark, I trust SAM more than me in changing ownership from the old UID to the new UID, _system_wide_. It starts a background process. So my hint is to use it, simple and effective.

Regards.