The chage command is used to modify user password expiry information. It enables you to view user account aging information, change the number of days between password changes and the date of the last password chage
To view a user account aging information, use the flag
-l as shown.
# chage -l anu
To set the date or number of days (since January 1, 1970) when the password was last changed, use the
-dflag as follows.
# chage -d 2018-02-11 anu
Next, you can also set the date or number of days (since January 1, 1970) on which the user’s account will no longer be accessible by using the
-E switch as shown in the following command.
In this case, once a user’s account is locked, he/she is required to contact the system administrator before being able to use the system again.
# chage -E 2018-02-16 anu
-W option allows you to set the number of days of warning before a password change is required. Considering the command below, the user anu will be warned 10 days prior to his password expiring.
# chage -W 10 anu
In addition, you can set the number of days of inactivity after a password has expired before the account is locked. This example means that after user anu’s password expires, his account will be inactive for 2 days before it is locked.
When the account becomes inactive, he must contact the system administrator before being able to use the system again.
# chage -I 2 anu