usermod

modify a user account

usermod [options] login Modifies the account .
-c
--comment comment
Normally modified using the chfn(1) utility.
-d
--home home_dir
login directory.
-m
--move-home
Move the contents of the user's home directory to the location which is created if it does not already exist.
Only with -d or --home . Will adapt the ownership of the files and copy the modes, ACL and extended attributes, but
manual changes might be needed afterwards.
-e
--expiredate YYYY-MM-DD
When the user account will be disabled.
An empty DATE disables the expiration
Requires a /etc/shadow file. A entry will be created if there were none.
-f
--inactive days
After a password expires until the account is permanently disabled.
0> disables the account as soon as the password has expired,
-1 disables the feature.
Requires a /etc/shadow file.
-g
--gid GROUP
The existing group name or number of the user's initial login group.
Any file from the user's home directory, owned by the previous primary group of the user, will be owned by this group.
The group ownership of files outside of the user's home directory must be changed manually.
-G
--groups GROUP1[,…
A list of supplementary groups which the user is also a member of.
The groups are subject to the same restrictions as the group given with -g
If the user is currently a member of a group which is not listed, the user will be removed from the group, unless -a is provided which appends the user to the current supplementary group list.
-a
--append
Add the user to the supplementary group(s). Use only with -G .
-l
--login NEW_LOGIN
>he 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.
-L
--lock
Lock a user's password. Puts a ! in front of the encrypted password, disabling the password. Not with -p or -U.
To lock the account (not only access with a password), set the EXPIRE_DATE to 1.
-p
--password PASSWORD
encrypted password, as returned by crypt(3). Not recommended because the password (or encrypted password) will be visible by users listing the processes.
Written to /etc/passwd or /etc/shadow which might differ from the password database configured in the PAM configuration.
-R
--root CHROOT_DIR
Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-s
--shell shell
login shell. Setting this field to blank selects the default login shell.
-u
--uid UID
numerical value of the user's ID.
must be unique, unless the -o option is used. The user's mailbox, and any files which the user owns and which are located in the user's home directory will have the file user ID changed automatically.
The ownership of files outside of the user's home directory must be fixed manually.
No checks will be performed with regard to the UID_MIN, UID_MAX, SYS_UID_MIN, or SYS_UID_MAX from /etc/login.defs.
-o
--non-unique
With -u allows setting user ID to a non-unique value.
-U
--unlock
Unlock a user's password. removes the '!' in front of the encrypted password. Don't use this option with -p or -L. To unlock the account (not only access with a password), also set the EXPIRE_DATE (for example to 99999, or to the EXPIRE value from /etc/default/useradd.
-v
--add-sub-uids FIRST-LAST
Add a range of subordinate uids to the user's account.
May be specified multiple times.
No checks are performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT from /etc/login.defs.
-V
--del-sub-uids FIRST-LAST
Remove a range of subordinate uids from the user's account.
May be specified multiple times.
When both --del-sub-uids and --add-sub-uids are specified, the removal of all subordinate uid ranges happens before any subordinate uid range is added.
No checks will be performed with regard to SUB_UID_MIN, SUB_UID_MAX, or SUB_UID_COUNT from /etc/login.defs.
-w
--add-sub-gids gidfirst-gidlast
Add a range of subordinate gids to the user's account.
May be specified multiple times to add multiple ranges to a users account.
No checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT from /etc/login.defs.
-W
--del-sub-gids FIRST-LAST
Remove a range of subordinate gids from the user's account. May be specified multiple times. When both --del-sub-gids and --add-sub-gids are specified, the removal of all subordinate gid ranges happens before any subordinate gid range is added.
o checks will be performed with regard to SUB_GID_MIN, SUB_GID_MAX, or SUB_GID_COUNT from /etc/login.defs.
-Z
--selinux-user SEUSER
The new SELinux user for the user's login.
A blank SEUSER will remove the SELinux user mapping for user LOGIN (if any).
The user must not be executing any processes when this command is being executed if the user's numerical user ID, the user's name, or the user's home directory is being changed.

Change the owner of any crontab files or at jobs manually.

Make any changes involving NIS on the NIS server.

CONFIGURATION

MAIL_DIR (string) The mail spool directory. This is needed to manipulate the mailbox when its corresponding user account is modified or deleted. If not specified, a compile-time default is used.
MAIL_FILE (string) Defines the location of the users mail spool files relatively to their home directory. The MAIL_DIR and MAIL_FILE variables are used by useradd, usermod, and userdel to create, move, or delete the user's mail spool.
MAX_MEMBERS_PER_GROUP (number) Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). The default value is 0, meaning that there are no limits in the number of members in a group. This feature (split group) permits to limit the length of lines in the group file. This is useful to make sure that lines for NIS groups are not larger than 1024 characters. If you need to enforce such limit, you can use 25. Note: split groups may not be supported by all tools (even in the Shadow toolsuite). You should not use this variable unless you really need it.
SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number) If /etc/subuid exists, the commands useradd and newusers (unless the user already have subordinate group IDs) allocate SUB_GID_COUNT unused group IDs from the range SUB_GID_MIN to SUB_GID_MAX for each new user. The default values for SUB_GID_MIN, SUB_GID_MAX, SUB_GID_COUNT are respectively 100000, 600100000 and 10000.
SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number) If /etc/subuid exists, the commands useradd and newusers (unless the user already have subordinate user IDs) allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN to SUB_UID_MAX for each new user. The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are respectively 100000, 600100000 and 10000.

FILES

/etc/group Group account information.
/etc/gshadow Secure group account information.
/etc/login.defs Shadow password suite configuration.
/etc/passwd User account information.
/etc/shadow Secure user account information.
/etc/subgid Per user subordinate group IDs.
/etc/subuid Per user subordinate user IDs.

SEE

chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8), groupdel(8), groupmod(8), login.defs(5), subgid(5), subuid(5), useradd(8), userdel(8).

chfn

change finger information

chfn [options] [LOGIN]

Changes user fullname, office room number, office phone number, and home phone number information for a user's account, output by finger and similar programs.
A normal user may only change the fields for their own account, subject to the restrictions in /etc/login.defs. The default prevents changing their fullname.
The superuser may change any field for any account or use -o to change the undefined portions of the GECOS field.
These fields must not contain any colons. Except for the other field, they should not contain any comma or equal sign.
Avoid non-US-ASCII characters,

-f
--full-name FULL_NAME
-r
--room ROOM_NUMBER
-R
--root CHROOT_DIR
Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
-h
--home-phone HOME_PHONE
-w
--work-phone WORK_PHONE
-o
--other OTHER
other GECOS information. used to store accounting information used by other applications, and can be changed only by a superuser.
-u
--help

If no options are selected, operates in interactive mode,

CONFIGURATION

/etc/login.defs

CHFN_RESTRICT (string) The values in the gecos field of /etc/passwd file may be changed by regular users using the chfn program.
Any combination of f, r, w, h for
Full name, Room number, Work phone, and Home phone,
yes is equivalent to rwh and no is equivalent to frwh. If not specified, only the superuser can make any changes.
The most restrictive setting is better achieved by not installing chfn SUID.