How to change a user's username on Linux?

I 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?

asked Apr 14, 2016 by anonymous

1 Answer

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
answered Apr 22, 2016 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...