Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change user id in linux

Tags:

linux

uid

Here is a short description of what I want to do:

User tom has id 1000. I'm calling usermod -u 2000 tom.

What happens exactly besides that the id of tom changes to 2000? Do files and folders which were owned by this user still remain by this user or do I have to explicitly set the owner again?

Thanks for your help!

like image 693
mryvlin Avatar asked Aug 15 '13 07:08

mryvlin


People also ask

How do I change the primary group ID in Linux?

To change the primary group a user is assigned to, run the usermod command, replacing examplegroup with the name of the group you want to be the primary and exampleusername with the name of the user account. Note the -g here. When you use a lowercase g, you assign a primary group.


1 Answers

usermod will change permissions for the user's files inside his home directory. files outside his home directory will have to be changed manually.

man usermod lists the following caveats:

You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID, the user's name, or the user's home directory is being changed. usermod checks this on Linux, but only check if the user is logged in according to utmp on other architectures.

You must change the owner of any crontab files or at jobs manually.

You must make any changes involving NIS on the NIS server.

like image 76
StianE Avatar answered Oct 06 '22 16:10

StianE