usermod

modify a user account

usermod [options] login Modifies the account .
-c
--comment comment
also modified using chfn.
-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.
Manual changes are also needed
-e
--expiredate YYYY-MM-DD
When the user account will be disabled.
An empty DATE disables the expiration
Requires /etc/shadow.
-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 /etc/shadow .
-g
--gid group
Group name or number for the user's initial login group.
When modifing: files from the user's home directory, owned by the previous primary group, will be changed to 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.
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). only with -G .
-l
--login new_login
The name of the user will be changed from to new_login.
Nothing else is changed. The user's home directory and mail spool should be renamed.
-L
--lock
Lock a user's password. Not with -p or -U.
To lock the account (not only access with a password), set EXPIRE_DATE 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, comma or equals. The other field may include comma or equal sign.

-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.
-usic
--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.


chpass aka chfn aka chsh

add or change user database information

chpass [-l location] [-u authname] [-s newshell] [user]

Edits the user database associated with user by default, the current user.

Cannot change the password on Open Directory systems, use the passwd.

The information is formatted and supplied to an editor for changes.

Only the information that the user is allowed to change is displayed.

-l location If not specified, chpass will perform a search for the user record on all available Open Directory nodes.
When specified, chpass will edit the user record on the directory node at the given location.
-u authname user name to use when authenticating to the directory node containing the user.
-s newshell Change shell to newshell.
Login: login name user name used to access the computer account.
Uid: login
Gid: login group GID or GNAME
Generated uid: UUID
Full Name: real name
Office Location: office location
Office Phone: office phone
Home Phone: home phone
Home Directory: home directory full path
Shell: login shell default Bourne shell, /bin/sh
Users may not change from/to a non-standard shell. Standard shells are defined in /etc/shells. cat /etc/shells # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using one of these shells. /bin/bash, csh, dash, ksh, sh, tcsh, zsh
The picture field is the path to a picture to be displayed for the user. sic
% chpass
Changing account information for eman.
Password for eman: 
chpass: Credentials could not be verified, user name or password is invalid.  
Credentials could not be verified, user name or password is invalid.

Open Directory

User database under the control of DirectoryService and may be physically located in different places, including the local Directory Service node, and remote LDAP servers. This version of chpass uses Open Directory to change user database information. It does not interact with the historic flat file database /etc/master.passwd

Environment

The vi(1) editor will be used unless the environment variable EDITOR is set to an alternate editor. When the editor terminates, the information is re-read and used to update the user database itself. Only the user, or the super-user, may edit the information associated with the user. FILES /etc/chpass.XXXXXX temporary copy of the data to edit /etc/shells the list of approved shells SEE ALSO login(1), passwd(1), getusershell(3), passwd(5)