31

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!

mryvlin
  • 622
  • 2
  • 7
  • 10

1 Answers1

27

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.

StianE
  • 3,055
  • 20
  • 20
  • is there any easy method to go through all files (not only home directory), check if they have the old uid and change it to the new one? – mryvlin Aug 15 '13 at 07:40
  • 7
    Is `find / -uid 1000 -exec chown -R tom {} \;` sufficient or do I have to do more? – mryvlin Aug 15 '13 at 07:46
  • 17
    You probably want to remove the `-R` in the `find`, as this makes the `chown` recursive. It is common to have files owned by a different user then the directory containing those files. – Dennis Dec 09 '13 at 18:09