DEV Community

Cover image for How to change or modify the name of the user in Linux?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to change or modify the name of the user in Linux?

Originally posted here!

To change the name of a user, you must use the usermod command followed by the -l flag (login name flag), the new name of the user, and finally the old name of the user.

# Syntax
sudo usermod -l new_user_name old_user_name
Enter fullscreen mode Exit fullscreen mode

Imagine that we already have a user named john in the system and want to change the name to roy. To do that we can use the usermod command like this,

# Change or modify the name of the user in Linux
sudo usermod -l roy john
Enter fullscreen mode Exit fullscreen mode
  • Sometimes you may need to use the sudo command before the usermod command to obtain the correct privileges to execute the command.

Try executing the above command in this online terminal to see the result.

That's all 😃!

Feel free to share if you found this useful 😃.


Top comments (0)