1836772 Members
2521 Online
110109 Solutions
New Discussion

changing the uid

 
sheevm
Regular Advisor

changing the uid

Hi All:

I have a request to change the users uid from 101 to 111. What does it require to do this.

I have lots of file created by this user in many directories.

I need to change the uid to this user(batch) and change all the files owned by this user?? Does the files owned by this user have the uid information kept somewhere?

What is the best way to achieve this? Pl help.

Raji
be good and do good
6 REPLIES 6
Domenico_5
Respected Contributor

Re: changing the uid

William Whiteford
Occasional Advisor

Re: changing the uid

Hi,

you can change the user id by executing
usermod -u 111

all the files in the users home directory will change automatically. For the rest you will have to change them manually.
Something like this should work
find / -user -exec chown {} \;
This will look everywhere and change the ownership of all files owned by olduserid to teh new user id.
Ken Hubnik_2
Honored Contributor

Re: changing the uid

User the usermod command. usermod -u 111.
James R. Ferguson
Acclaimed Contributor

Re: changing the uid

Hi:

You can do this with 'usermod' and 'find'. 'usermod will perform the necessary changes to the 'etc/passwd'. Use 'find' to find and change the ownership:

# find / -user oldid -exec chown newname {} \;

Regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: changing the uid

usermod -u 111 tom

will change the uid of user tom to 111. It will not change the ownerships of the files. Man usermod for details.


To do that:

find / -user 101 -exec chown tom {} \;

I dont like to start a find from / but this may be your only choice unless for example you know that all his files will be located in ,perhaps 3 directorties /usr,/home, & /data,

in that case:

find /usr /home /data -user 101 -exec chown tom {} \;

Man find for details.

If it ain't broke, I can fix that.
W.C. Epperson
Trusted Contributor

Re: changing the uid

Now that you know how to do the tasks from the command line, you'll be prepared to fix things if SAM hoses them up:

sam->Accounts for users and groups->Users->Actions->Modify

Sam will take care of usermod and file ownerships, reliably in my experience unless you restart the system while the batch jobs are running. If you change username instead of uid, SAM will get everything except the name of the sendmail mbox, if there is one, so you'd have to do that manually.
"I have great faith in fools; self-confidence, my friends call it." --Poe