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.
A username change doesn't change the uid or guid - so there should be no problem with doing this:
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: