Go to main content

man pages section 8: System Administration Commands

Exit Print View

Updated: Thursday, June 13, 2019
 
 

usermod(8)

Name

usermod - modify a user's login information on the system

Synopsis

usermod [-u uid [-o]] [-g group] [-G [+|-]group [, group...]]
     [-d dir [-m]] [-s shell] [-c comment] [-l new_name]
     [-f inactive] [-e expire]
     [-A [+|-]authorization [,authorization]]
     [-P [+|-]profile [,profile]] [-R [+|-]role [,role]]
     [-K key[+|-]=value] [-S repository] [-q qualifier] login
usermod -S ldap -K key[+|-]=value [-q qualifier] default@

Description

The usermod utility modifies a user's login definition on the system. It changes the definition of the specified login and makes the appropriate login-related system file and file system changes.

For accounts that are created using –S ldap, the default values for any of the –K attributes may be specified using –S ldap and the special value default@ as the login name.

The system file entries created with this command have a limit of 512 characters per line. Specifying long arguments to several options might exceed this limit.

For users not present in the local files repository, by specifying –S option, files will create/modify a local files entry for the user.

An administrator must be granted the User Security Profile to modify the security attributes for an existing user. To be able to modify the non-security attributes of an existing user requires the User Management Profile. The authorizations required to set the various fields in passwd, shadow and user_attr can be found in passwd(5), shadow(5), and user_attr(5). The authorizations required to assign groups can be found in group(5).

Options

The following options are supported:

–A [+|-]authorization

One or more comma separated authorizations as defined in auth_attr(5). Only a user or role who has grant rights to the authorization can assign it to an account. This replaces any existing authorization setting. If no authorization list is specified, the existing setting is removed.

A prefix + adds the authorization to the existing authorization; a prefix - removes the authorization from the existing authorization. With no prefix, authorization replaces the existing authorization.

–c comment

Specify a comment string. comment can be any text string. It is generally a short description of the login, and is currently used as the field for the user's full name. This information is stored in the user's passwd entry.

–d dir

Specify the new home directory of the user. It defaults to base_dir/login, where base_dir is the base directory for new login home directories, and login is the new login. This creates or modifies an auto_home entry for the user.

The argument to the option can be specified as server: dir where server is the hostname of the machine on which the home directory resides and dir is the path to the user's home directory. If the server is a remote host then the home directory needs to be created on the remote host for the system to mount it, when the user logs in. If no server name is specified then the home directory will be created on the host where the command is executed, when the –m option is used.

–e expire

Specify the expiration date for a login. After this date, no user will be able to access this login. The expire option argument is a date entered using one of the date formats included in the template file /etc/datemsk. See getdate(3C).

For example, you may enter 10/6/90 or October 6, 1990. A value of `` '' defeats the status of the expired date.

–f inactive

Specify the maximum number of days allowed between uses of a login ID before that login ID is declared invalid. Normal values are positive integers. A value of 0 defeats the status.

–g group

Specify an existing group's integer ID or character-string name. It redefines the user's primary group membership.

–G [+|-]group

An existing group's integer ID or character-string name. It defines the new user's supplementary group membership. Duplicates between group with the –g and –G options are ignored. No more than NGROUPS_MAX groups can be specified. GIDs 0-99 are reserved for allocation by the Oracle Solaris Operating System.

A prefix + adds the group to the existing group; a prefix - removes the group from the existing group. With no prefix, group replaces the existing group.

–K key[+|-]= value

Replace existing or add to a user's key=value pair attributes. Multiple –K options can be used to replace or add multiple key=value pairs. However, keys must not be repeated. The generic –K option with the appropriate key can be used instead of the specific implied key options (–A, –P, –R, –p). See user_attr(5) for a list of valid keys. Values for these keys are usually found in man pages or other sources related to those keys. For example, see project(5) for guidance on values for the project key. Use the command ppriv(1) with the –v and –l options for a list of values for the keys defaultpriv and limitpriv. If no value is specified, the existing key is removed.

The keyword type can be specified with the value role or the value normal. When using the value role, the account changes from a normal user to a role; using the value normal keeps the account a normal user.

As a role account, no roles (–R or roles=value) can be present.

A prefix + adds the value to the existing value; a prefix - removes the value from the existing value. With no prefix, value replaces the existing value.

The prefix +/- operation is applicable only to the following keys: auths, profiles, auth_profiles, roles, project, limitpriv, defaultpriv, auth_profiles, and access_times.

–l new_logname

Specify the new login name for the user. See passwd(5) for the requirements for usernames.

–m

Move the user's home directory to the new directory specified with the –d option. If the directory already exists, it must have permissions read/write/execute by group, where group is the user's primary group. If the server name specified to the –d option is a remote host then the system will not attempt to create the home directory.

If the directory does not already exist, a new ZFS dataset will be created. In the global zone, the dataset is created as rpool/export/home/rolename. For non-global zones, the dataset will be created as ROOT-dataset/export/home/rolename. The mountpoint for the ZFS dataset is /export/home/rolename by default. If –d path is specified and it is a path on the local machine, the dataset will be mounted at the specified location. The role is delegated permissions to create ZFS snapshots and promote them. The newly created dataset will inherit the encryption setting from its parent. If it is encrypted, the role is granted permission to change its wrapping key.

–o

This option allows the specified UID to be duplicated (non-unique).

–P [+|-]profile

One or more comma-separated rights profiles defined in prof_attr(5). This replaces any existing profile setting in user_attr(5). If an empty profile list is specified, the existing setting is removed.

A prefix + adds the profile to the existing profile; a prefix - removes the profile from the existing profile. With no prefix, profile replaces the existing profile.

–q qualifier

The name of a host or netgroup which qualifies where the extended attributes (specified through the –K, –P, –A, and –R options) are applicable. The prefix @ is required to indicate that the qualifier is a netgroup name. The –q option is only valid if the user account is maintained in the LDAP name service.

–R [+|-]role

One or more comma-separated roles (see roleadd(8)). This replaces any existing role setting. If no role list is specified, the existing setting is removed.

A prefix + adds the role to the existing role; a prefix - removes the role from the existing role. With no prefix, role replaces the existing role.

–s shell

Specify the full pathname of the program that is used as the user's shell on login. The value of shell must be a valid executable file.

–S repository

The valid repositories are files, ldap. The repository specifies which name service will be updated. The default repository is files. When the repository is files, the authorizations, profiles, and roles can be present in other name service repositories and can be assigned to a user in the files repository. When the repository is ldap, all the assignable attributes must be present in the ldap repository.

–u uid

Specify a new UID for the user. It must be a non-negative decimal integer less than MAXUID as defined in <param.h>.

Operands

The following operands are supported:

login

An existing login name to be modified.

Examples

Example 1 Assigning Privileges to a User

The following command adds the privilege that affects high resolution times to a user's initial, inheritable set of privileges.

# usermod -K defaultpriv=basic,proc_clock_highres jdoe

This command results in the following entry in user_attr:

jdoe::::type=normal;defaultpriv=basic,proc_clock_highres
Example 2 Removing a Privilege from a User's Limit Set

The following command removes the privilege that allows the specified user to create hard links to directories and to unlink directories.

# usermod -K limitpriv=all,!sys_linkdir jdoe

This command results in the following entry in user_attr:

jdoe::::type=normal;defaultpriv=basic,limitpriv=all,!sys_linkdir
Example 3 Removing a Privilege from a User's Basic Set

The following command removes the privilege that allows the specified user to examine processes outside the user's session.

# usermod -K defaultpriv=basic,!proc_session jdoe

This command results in the following entry in user_attr:

jdoe::::type=normal;defaultpriv=basic,!proc_session;limitpriv=all
Example 4 Assigning a Role to a User

The following command assigns a role to a user. The role must have been created prior to this command through use of roleadd(8).

# usermod -R mailadm jdoe

This command results in the following entry in user_attr:

jdoe::::type=normal;roles=mailadm;defaultpriv=basic;limitpriv=all
Example 5 Granting Several Rights to a User

The following command grants the solaris.zone.manage authorization, Project Management rights profile, sets limit privilege to basic and assigns the mailadm role to the user.

# usermod -A 'solaris.zone.manage' -P 'Project Management' -K limitpriv=basic
 -R mailadm -S files jdoe_ldap

This command results in the following entry in user_attr:

jdoe_ldap::::auths=solaris.zone.manage;profiles=ProjectManagement;limitpriv=basic;
roles=mailadm
Example 6 Granting an Authenticated Rights Profile to a User

The following command adds an authenticated rights profile to a trusted user.

# usermod -K auth_profiles+="Network Security" jdoe
Example 7 Removing All Profiles from a User

The following command removes all profiles that were granted to a user directly. The user will still have any rights profiles that are granted by means of the PROFS_GRANTED key in policy.conf(5).

# usermod -P "" jdoe

Exit Status

In case of an error, usermod prints an error message and exits with one of the following values:

1

No permission for attempted operation.

2

The command syntax was invalid. A usage message for the usermod command is displayed.

3

An invalid argument was provided to an option.

4

The gid or uid given with the –u option is already in use.

5

The password and shadow files are not consistent with each other. pwconv(8) might be of use to correct possible errors. See passwd(5) and shadow(5).

6

The login to be modified does not exist, the gid or the uid does not exist.

7

The group, passwd, or shadow file is missing.

9

A group or user name is already in use.

10

Cannot update the passwd, shadow, or user_attr file.

11

Insufficient space to move the home directory (–m option).

12

Unable to create, remove, or move the new home directory.

13

Requested login is already in use.

14

Unexpected failure.

16

Unable to update the group database.

17

Unable to update the project database.

18

Insufficient authorization.

19

Does not have role.

20

Does not have profile.

21

Does not have privilege.

22

Does not have label.

23

Does not have group.

24

System not running Trusted Extensions.

25

Does not have project.

26

Unable to update auto_home.

Files

/etc/group

system file containing group definitions

/etc/datemsk

system file of date formats

/etc/passwd

system password file

/etc/shadow

system file containing users' encrypted passwords and related information

/etc/user_attr

system file containing additional user and role attributes

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
Interface Stability
Committed

See Also

auths(1), passwd(1), profiles(1), getdate(3C), auth_attr(5), passwd(5), policy.conf(5), prof_attr(5), user_attr(5), attributes(7), groupadd(8), groupdel(8), groupmod(8), logins(8), pwconv(8), roleadd(8), roledel(8), rolemod(8), useradd(8), userdel(8)

Notes

The usermod utility modifies definitions in the passwd, shadow, group, project, and user_attr databases in the scope (default or specified). The utility will verify the uniqueness of user name and user ID against the external name service.