I have a user with a username of jsmith who was recently married and wants her login to reflect her new married name: jdoe. I understand that usermod will make the changes but I am concerned about implications that I haven't thought of. I want to do the following:

mkdir /home/jdoe chown jdoe:jdoe /home/jdoe
usermod -l jdoe -m /home/jdoe jsmith cp -rp /home/jsmith/* /home/jdoe

The user belongs to a common group so there should be no GID issues and I've run find commands with no results looking for files owned by her GID.

From my experimentation: The usermod command changes ownership of all files with the UID of jsmith to jdoe. There are no files with her GID so that is moot. I'll have to go in manually to /etc/group and change her username in any group where she is a member.

Essentially my questions are these: Will /etc/shadow and /etc/gshadow need to be altered by hand? Am I missing anything?


Assuming that this is a locally authenticated user (as it sounds like it is), you should be able to only change /etc/passwd, /etc/shadow, and /etc/group, then mv her old home directory name to the new directory name.

That would ensure that she has the same UID as before so no file permission errors will crop up. The only remnants of her old login would exist in log files.

  • 1
    You will find that a lot of programs still refer to the old home directory. Either live with it and fix them when they break or set up a symlink for all time. You will also find references to the username in places you weren't expecting. In some cases, it's just easier to set up a new username. – David Pashley Jun 5 '09 at 13:51
  • David's idea is great. ln -s /home/newname /home/oldname – Matt Simmons Jun 5 '09 at 14:02
  • David, I'm finding that out now. The user modification went smoothly but I'm having some minor issues that I'm working out. I think in my case it was worth-while to modify. Thanks again. – oneodd1 Jun 5 '09 at 17:30

A username change doesn't change the uid or guid - so there should be no problem with doing this:

mv /home/olddir /home/newdir

usermod -l newname oldname
usermod -d /home/newdir newname
  • Thanks Martynas, I appreciate the examples. As an aside, I would have given you the accepted answer but Matt answered first. – oneodd1 Jun 5 '09 at 13:48

If you do need to update the user ID, you can do it using find. For example, if old the UID is 500 and the new UID is 600:

find / -user 500 -print0 | xargs -0 chown 600
  • Thanks to you also Kyle. Another good example that I'll store away for future reference. – oneodd1 Jun 5 '09 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.