Ubuntu 10.04 – How to rename a user
A user can easily be renamed in the desktop using the Users and Groups applet found in Menu: System –> Administration–> Users and Groups. However, renaming a user this way only changes his Full Name and does not fix up the home directory or other references. Instead, to fully rename a user, the rename must be performed from the console.
A user can not be renamed while he is logged in. Use a different admin user to perform the rename; create a temporary admin user that has rights to perform the rename if necessary (Menu: System –> Administration –> Users and Groups).
- Ensure that the desktop is logged out.
- Ctrl+Alt+F1 to get a console and log in as the admin user.
- Rename the old username to the new username (including the home directory):
usermod -l <newname> -d /home/<newname> -m <oldname>
- Move the old user’s group to the new user’s group (the group name is typically the same name as the username):
groupmod -n <newgroup> <oldgroup>
- Exit out of the console.
- Ctrl+Alt+F7 or Ctrl+Alt+F8 to return to the desktop login.
- Login and test the newly renamed user.
- To fix up the renamed user’s display name in Gnome.
- Menu: System -> Administration -> Users and Groups
- Select the renamed user.
- Beside the user’s old name click Change…
- Set the user’s new Full Name.
- Remove the temporary admin user if necessary (Menu: System –> Administration –> Users and Groups). You may need to reboot if the system reports that the user is still logged in.
Note: If your Linux image is running in VMware then CTRL-ALT-F1 won’t work directly since VMware uses CTRL-ALT to release the cursor. Instead in VMware use CTRL-ALT-Space, then let go of space, then press F1 or F8 while still holding CTRL-ALT.
Reference: