Setting User Account Validity Period

To ensure user security, you need to set the validity period of a user. You can run the chage command to set the validity period of a user.

Command:

chage [-m mindays] [-M maxdays] [-d lastday] [-I inactive] [-E expiredate] [-W warndays] user

For example, to change the validity period of user test to 90 days, run the following command:

chage -M 90 test

Table 1 describes the parameters.

Table 1 Setting user account validity period

Parameter

Description

-m

Minimum time (in days) for which the password must be used. The password cannot be changed during this period. The value 0 indicates that the password can be changed at any time.

-M

Maximum validity period (days) of a password. The value -1 indicates that the validity check of the password can be disabled. The value 99999 indicates that the validity period is unlimited.

-d

Date when the password was changed the last time.

-I

Maximum idle period (in days) after which the user account will be disabled. After the specified time period has expired, the password will be invalid.

-E

Date when the user account expires. The user account is unavailable when the account validity period has expired.

-W

Number of days in advance users are notified that their passwords are about to expire.

-l

Lists the current settings. It helps non-privileged users to determine the time when their passwords or accounts expire.

  • Table 1 lists only common parameters. You can run the chage --help command to display detailed parameter description.
  • The date format is YYYY-MM-DD. For example, chage -E 2017-12-01 test indicates that the password of user test expires on December 1, 2017.
  • User is mandatory. Replace it with the actual user name. The default user name is root.