# phpman > man > usermod(8)

[USERMOD(8)](https://www.chedong.com/phpMan.php/man/USERMOD/8/markdown)                           System Management Commands                           [USERMOD(8)](https://www.chedong.com/phpMan.php/man/USERMOD/8/markdown)



## NAME
       usermod - modify a user account

## SYNOPSIS
       **usermod** [_options_] _LOGIN_

## DESCRIPTION
       The **usermod** command modifies the system account files to reflect the changes that are
       specified on the command line.

## OPTIONS
       The options which apply to the **usermod** command are:

### -a --append
           Add the user to the supplementary group(s). Use only with the **-G** option.

### -b --badnames
           Allow names that do not conform to standards.

### -c --comment
           The new value of the user's password file comment field. It is normally modified using
           the [**chfn**(1)](https://www.chedong.com/phpMan.php/man/chfn/1/markdown) utility.

### -d --home
           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.

### -e --expiredate
           The date on which the user account will be disabled. The date is specified in the format
           _YYYY-MM-DD_.

           An empty _EXPIRE_DATE_ argument will disable the expiration of the account.

           This option requires a /etc/shadow file. A /etc/shadow entry will be created if there
           were none.

### -f --inactive
           The number of days after a password expires until the account is permanently disabled.

           A value of 0 disables the account as soon as the password has expired, and a value of -1
           disables the feature.

           This option requires a /etc/shadow file. A /etc/shadow entry will be created if there
           were none.

### -g --gid
           The group name or number of the user's new initial login group. The group must exist.

           Any file from the user's home directory owned by the previous primary group of the user
           will be owned by this new group.

           The group ownership of files outside of the user's home directory must be fixed manually.

### -G --groups
           A list of supplementary groups which the user is also a member of. Each group is
           separated from the next by a comma, with no intervening whitespace. The groups are
           subject to the same restrictions as the group given with the **-g** option.

           If the user is currently a member of a group which is not listed, the user will be
           removed from the group. This behaviour can be changed via the **-a** option, which appends
           the user to the current supplementary group list.

### -l --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 or mail spool should probably be renamed manually
           to reflect the new login name.

### -L --lock
           Lock a user's password. This puts a '!' in front of the encrypted password, effectively
           disabling the password. You can't use this option with **-p** or **-U**.

           Note: if you wish to lock the account (not only access with a password), you should also
           set the _EXPIRE_DATE_ to _1_.

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

### -o --non-unique
           When used with the **-u** option, this option allows to change the user ID to a non-unique
           value.

### -p --password
           The encrypted password, as returned by [**crypt**(3)](https://www.chedong.com/phpMan.php/man/crypt/3/markdown).

           **Note:** This option is not recommended because the password (or encrypted password) will be
           visible by users listing the processes.

           The password will be written in the local /etc/passwd or /etc/shadow file. This might
           differ from the password database configured in your PAM configuration.

           You should make sure the password respects the system's password policy.

### -R --root
           Apply changes in the _CHROOT_DIR_ directory and use the configuration files from the
           _CHROOT_DIR_ directory.

### -P --prefix
           Apply changes in the _PREFIX_DIR_ directory and use the configuration files from the
           _PREFIX_DIR_ directory. This option does not chroot and is intended for preparing a
           cross-compilation target. Some limitations: NIS and LDAP users/groups are not verified.
           PAM authentication is using the host files. No SELINUX support.

### -s --shell
           The name of the user's new login shell. Setting this field to blank causes the system to
           select the default login shell.

### -u --uid
           The new numerical value of the user's ID.

           This value must be unique, unless the **-o** option is used. The value must be non-negative.

           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.

### -U --unlock
           Unlock a user's password. This removes the '!' in front of the encrypted password. You
           can't use this option with **-p** or **-L**.

           Note: if you wish to unlock the account (not only access with a password), you should
           also set the _EXPIRE_DATE_ (for example to _99999_, or to the **EXPIRE** value from
           /etc/default/useradd).

### -v --add-subuids
           Add a range of subordinate uids to the user's account.

           This option may be specified multiple times to add multiple ranges to a users account.

           No checks will be performed with regard to **SUB**___**UID**___**MIN**, **SUB**___**UID**___**MAX**, or **SUB**___**UID**___**COUNT**
           from /etc/login.defs.

### -V --del-subuids
           Remove a range of subordinate uids from the user's account.

           This option may be specified multiple times to remove multiple ranges to a users account.
           When both **--del-subuids** and **--add-subuids** 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-subgids
           Add a range of subordinate gids to the user's account.

           This option 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-subgids
           Remove a range of subordinate gids from the user's account.

           This option may be specified multiple times to remove multiple ranges to a users account.
           When both **--del-subgids** and **--add-subgids** are specified, the removal of all subordinate
           gid ranges happens before any subordinate gid range is added.

           No checks will be performed with regard to **SUB**___**GID**___**MIN**, **SUB**___**GID**___**MAX**, or **SUB**___**GID**___**COUNT**
           from /etc/login.defs.

### -Z --selinux-user
           The new SELinux user for the user's login.

           A blank _SEUSER_ will remove the SELinux user mapping for user _LOGIN_ (if any).

## CAVEATS
       You must make certain that the named user is not 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.  **usermod** checks this on Linux. On other platforms it only uses utmp to
       check if the user is logged in.

       You must change the owner of any **crontab** files or **at** jobs manually.

       You must make any changes involving NIS on the NIS server.

## CONFIGURATION
       The following configuration variables in /etc/login.defs change the behavior of this tool:

### LASTLOG___UID___MAX (number)
           Highest user ID number for which the lastlog entries should be updated. As higher user
           IDs are usually tracked by remote user identity and authentication services there is no
           need to create a huge sparse lastlog file for them.

           No **LASTLOG**___**UID**___**MAX** option present in the configuration means that there is no user ID
           limit for writing lastlog entries.

### 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 65536.

### 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 65536.

## 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 ALSO
       [**chfn**(1)](https://www.chedong.com/phpMan.php/man/chfn/1/markdown), [**chsh**(1)](https://www.chedong.com/phpMan.php/man/chsh/1/markdown), [**passwd**(1)](https://www.chedong.com/phpMan.php/man/passwd/1/markdown), [**crypt**(3)](https://www.chedong.com/phpMan.php/man/crypt/3/markdown), [**gpasswd**(8)](https://www.chedong.com/phpMan.php/man/gpasswd/8/markdown), [**groupadd**(8)](https://www.chedong.com/phpMan.php/man/groupadd/8/markdown), [**groupdel**(8)](https://www.chedong.com/phpMan.php/man/groupdel/8/markdown), [**groupmod**(8)](https://www.chedong.com/phpMan.php/man/groupmod/8/markdown),
       [**login.defs**(5)](https://www.chedong.com/phpMan.php/man/login.defs/5/markdown), [**subgid**(5)](https://www.chedong.com/phpMan.php/man/subgid/5/markdown), [**subuid**(5)](https://www.chedong.com/phpMan.php/man/subuid/5/markdown), [**useradd**(8)](https://www.chedong.com/phpMan.php/man/useradd/8/markdown), [**userdel**(8)](https://www.chedong.com/phpMan.php/man/userdel/8/markdown).



shadow-utils 4.8.1                           02/06/2024                                   [USERMOD(8)](https://www.chedong.com/phpMan.php/man/USERMOD/8/markdown)
