System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change the uid and gid of a user and update all files,symbolic links with new uid/gid?

 
OBSUV0091126257
Occasional Contributor

How to change the uid and gid of a user and update all files,symbolic links with new uid/gid?

How can we change the uid and gid of a user and also update the user id/gid for all files ,symbolic links owned by that user/group on the system ?

Please provide me all the steps for the same.

1 REPLY

Re: How to change the UID and GID of a user and update all files, with new UID/GID?

I don't know if sam allows you to change IDs?  (I see a modify with the UID field.)

There is also usermod(1m) not sure if it changes the file ownership?

If not, you could use vipw(1m) to edit /etc/passwd.  And then you need to edit /etc/group for secondary groups.

Then you need a find(1) to search for all files with that UID or GID and then use chown/chgrp to change the values.

If the files don't have the same UID/GID, your -exec script for chown/chgrp will have to check the current owner/group and if it doesn't match, then don't do the ch*.

 

There is no need to worry about ownership of symlinks.