Sometimes it's necessary to rename a local user on a server or workstation running Linux. This can be done quickly with a single command.
This also works for UNIX systems
The command below allows you to rename the user
usermod --login NEWLOGIN --move-home --home PATHTONEWHOME OLDLOGIN
- NEWLOGIN: The user's new login
- PATHTONEWHOME: Path to the user's new home folder
- OLDLOGIN: The user's login to be renamed
If this user is on the sudoers list, remember to update their login in the list of authorized users.
Finally, it's useful to rename the user's home group. This can be done with the following command:
groupmod --new-name NEWLOGIN OLDLOGIN
