Setting User Account Validity Period
Run the chage command to set the validity period of a user account for security purposes.
Command:
chage [-m mindays] [-M maxdays] [-d lastday] [-I inactive] [-E expiredate] [-W warndays] user
Table 9-5 describes the parameters.
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 |
Validity period (days) of the password. If this parameter is set to -1, this check item is ignored and the user password will not expire. This poses security risks. Therefore, exercise caution when setting this parameter. |
-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 user name and password validity information. This information helps non-privileged users to determine when to change their passwords. |
- Table 9-5 lists only common parameters. You can run the chage --help command to display detailed parameter description.
- The date is in the format of YYYY-MM-DD. For example, chage -E 2019-12-01 test indicates that the user account test will expire on December 1, 2019.
- If User is not specified, the default user root will be used.
For example, to change the validity period of the user account test to December 31, 2019, run the following command:
chage -E 2019-12-31 test