Linux chage command
The chage command is used to set account expiration date for user. It also changes the time the user’s password will expire.
$ chage [options] LOGIN
#1 – Set Password Expiry Days of User
Set the number of days to expire password after last change. It means the user will force to change its password after 15 days of last change.
$ chage -M 15 testuser
#2 – Set Account Password Expiry Warning Date
You can also set the password expiry warning date. So that user gets alert for the password expiration and to change the password.
$ chage -W 3 testuser
#3 – Set Account Expiry Date of User
You can also set the expiry date of any user in Linux system. The account will automatically deactivate after passing the expiry date. Use the following command to set the expiration date of account to Oct 28, 2019.
$ chage --expiredate "28 OCT 2019" testuser
#4 – List Account Aging Details
Run the following command to view the aging details of the user account.
$ chage -l testuser
#5 – Disable Password and Account Expiry
You can disable the password and account expiry any time using the following command.
$ chage -I -1 -m 0 -M 99999 -E -1 testuser
#6 – Force User to Change Password
You can also set the expiry date to 0 to force a user to change accounts password on next login.
$ chage –d 0 testuser