How can I rename a Unix user?

Under Linux, the usermod command changes user names. It modifies the system account files to reflect the changes that are specified on the command line.

To change just the username:

usermod --login new_username old_username

To change the username and home directory name:

usermod --login new_username --move-home --home path_to_the_new_home_dir old_username

You may also want to change the name of the group associated with the user:

groupmod --new-name new_username old_username

Leave a Comment