Change user id in linux

mryvlin picture mryvlin · Aug 15, 2013 · Viewed 30.8k times · Source

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!

Answer

StianE picture StianE · Aug 15, 2013

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.