usermod
Modify a user account
Overview
Modifies an existing user account. It can change most attributes of a user account specified on the command line.
Syntax
usermod [OPTION]... LOGINCommon Options
-c comment, --comment commentNew value of the user's password file comment field.
-d home_dir, --home home_dirNew value of the user's login directory.
-e expire_date, --expiredate expire_dateThe date on which the user account will be disabled.
-g initial_group, --gid initial_groupThe group name or number of the user's new initial login group.
-G group,[,...], --groups group,[,...]A list of new supplementary groups. If used with -a, append to current groups.
-a, --appendAppend the user to the supplementary groups mentioned by the -G option without removing the user from other groups.
-l new_login, --login new_loginThe name of the user will be changed from LOGIN to NEW_LOGIN.
-L, --lockLock the user's password. This puts a '!' in front of the encrypted password.
-U, --unlockUnlock the user's password. This removes the '!' in front of the encrypted password.
-m, --move-homeMove the content of the user's home directory to the new location (use with -d).
-s shell, --shell shellThe name of the user's new login shell.
-u uid, --uid uidNew numerical value of the user's ID.
Examples
Updates the comment (full name) for user jdoe.
Changes jdoe's login shell to zsh.
Adds jdoe to the sudo and www-data supplementary groups (without removing existing ones).
Renames user oldname to newname.
Locks the tempuser account.
Unlocks the tempuser account.
Moves jdoe's home directory to /home/new_home and updates login details.
Sets an expiry date for the contractor account.