How to change a user’s username on Linux?
Posted on In QAI want to rename a user’s username on Linux. For example, rename user u1 to user1. How to change a user’s username on Linux?
You can use the usermod command to modify the user’s info.
For changing the user name, you can use the -l
option:
-l, –login NEW_LOGIN
The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user’s home directory or mail spool should probably be renamed manually to reflect the new login name.
For your specific example, the command will be (run as root or by sudo)
usermod -l user1 u1