Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing uid and groupid

Status
Not open for further replies.

KenCunningham

Technical User
Mar 20, 2001
8,475
GB
Hi - Happy New Year to all those it applies to!

I'm trying to set up a test environment but have hit a snag when trying to refresh it from a live one. Basically two 'administrative' users have been set up on both machines, but their uids and groupids are not the same. For example:

On machine1 user1 has a uid of 202 and a primary group of 202, whereas on machine2 user1 has a uid of 204 and a groupid of 203.

The same software and filesystems are installed on each machine. Is it possible to change the uid and groupid on machine2 so that it matches that on machine1 (I have confirmed that there are no other users with the same target uid/groupid on machine2). I know in some other flavours of *nix this has caused me grief when the software has already been installed (to the extent that we had to write a routine to find and change the 'lost' ones), but wondered whether anyone has experienced the same problem in AIX and come up with a solution. Of course, it would be great if smitty could do this (I haven't tried - didn't want the fallout if it didn't!) simply by resetting the userid and groupid there - does anyone know whether smitty is clever enough to do this? Any and all contributions gratefully received.
 
If i understand, you just want to have the UID & GID matching on your two machines.

Smitt can do that:

For the UID:

-> Security & Users ->Users
-> Change / Show Characteristics of a User

For the GID

-> Security & Users ->Groups
-> Change / Show Characteristics of a Group

 
Gloups - thanks. I guess my major concern is whether if I change the UID and GID through smitt, whether this will be reflected and cascaded through every file owned by these users in each filesystem, of which there are many. I seem to recollect (though maybe not precisely), that the uid and gid are fundamental to the ownerships and group permissions, rather than the user name itself (which is more of a cosmetic thing for we humans), and it was this which caused the problems in the past.
 
ok i understand, a solution may be a shell script like that

find / -ls -ls | tr -s ' ' | cut -d ' ' -f 6,7,12 | grep YOUR_OLD_UID | grep YOU_OLD_GID

you may use something like that being more fine with the grep and combining with a chown command but it will be long for a big nuber of files.

There is probably a cleanest way to do it
 
There's also two options of the find command:
find / -user (OLD_UID) -exec chown NEW_UID {} \;
find / -group (OLD_GID) -exec chgrp NEW_GID {} \;
Don't do the short way of changing directly user and gid, often some files belongs to an user but not to the primary gid.
In Example, in DB2 installations there are some files owned by root but accessible from users of db2xxxx group
 
Thanks guys, I think you've confirmed my suspicions. I'll let you know how I get on. Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top