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 change.
Once you have set password expiry and aging information, this information is used by the system to determine when a user must change his/her password. Normally, companies or organizations have certain security policies that demand users to change passwords regularly: this can be a simple way to enforce such policies as we explained below.
To view a user account aging information, use the
-l flag as shwon.
# chage -l vyga
To set the date or number of days (since January 1, 1970) when the password was last changed, use the
-d flag as follows.
# chage -d 2018-02-11 vyga
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 vyga
-W option allows you to set the number of days of warning before a password change is required. Considering the command below, the user vyga will be warned 10 days prior to his password expiring.
# chage -W 10 vyga
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 vyga’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 vyga
For more information, refer to the chage man page.
# man chage