See man usermod
:
SYNOPSIS
usermod [options] LOGIN
-d, --home HOME_DIR
The user's new login directory.
If the -m option is given, the contents of the current home
directory will be moved to the new home directory, which is
created if it does not already exist.
-m, --move-home
Move the content of the user's home directory to the new location.
This option is only valid in combination with the -d (or --home)
option.
usermod will try to adapt the ownership of the files and to copy
the modes, ACL and extended attributes, but manual changes might
be needed afterwards.
-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
name should probably be changed manually to reflect the new login
name.
So you want
sudo usermod -m -d /home/new_login_name old_login_name
sudo usermod -l new_login_name old_login_name
The first command will move your login directory; the second command will edit the relevant files that reference your name (/etc/passwd
, /etc/shadow
, /etc/groups
) of old_login_name
to new_login_name
. You didn't ask, but you may also want to change your group name as with groupmod
in an analogous fashion (sudo groupmod -n new_group_name old_group_name
).