Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks Matt. I see you are no longer 1337... –  oneodd1 Jun 5 '09 at 13:46
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
add comment

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
share|improve this answer
    
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
add comment

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
share|improve this answer
    
Thanks to you also Kyle. Another good example that I'll store away for future reference. –  oneodd1 Jun 5 '09 at 13:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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