Donate : Link
Medium Blog : Link
Applications : Link
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.
~/codeFactory$ chage --help
Usage: chage [options] LOGIN
Options:
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, --help display this help message and exit
-i, --iso8601 use YYYY-MM-DD when printing dates
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --list show account aging information
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, --maxdays MAX_DAYS set maximum number of days before password
change to MAX_DAYS
-R, --root CHROOT_DIR directory to chroot into
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
1. -l option: use this option to view the account aging information.
~# chage -l root
Last password change : Aug 17, 2021
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
2. -d option: use this option to set the last password change date to your specified date in the command.
~# chage -d 2021-08-18 root
~# chage -l root
Last password change : Aug 18, 2021
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
3. -E option: use this option to specify the date when the account should expire.
~# chage -E 2021-08-31 root
~# chage -l root
Last password change : Aug 18, 2021
Password expires : never
Password inactive : never
Account expires : Aug 31, 2021
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
4. -m or -M option: use this option to specify the maximum and minimum number of days between password change.
~# chage -M 15 root
~# chage -m 5 roo
~# chage -l root
Last password change : Aug 18, 2021
Password expires : Sep 02, 2021
Password inactive : never
Account expires : Aug 31, 2021
Minimum number of days between password change : 5
Maximum number of days between password change : 15
Number of days of warning before password expires : 7
5. -I (capital i) option: use this option to specify the number of days the account should be inactive after its expiry. It is necessary that the user should change the password after it expires, this command is useful when the user does not login after its expiry. Even after this inactivity period if the password is not changed then the account is locked and the user should approach the admin to unlock it.
~# chage -I 5 root
~# chage -l root
Last password change : Aug 18, 2021
Password expires : Sep 02, 2021
Password inactive : Sep 07, 2021
Account expires : Aug 31, 2021
Minimum number of days between password change : 5
Maximum number of days between password change : 15
Number of days of warning before password expires : 7
6. -W option: use this option to give prior warning before the password expires.The input given in the command is the number of days prior to the expiry date when the warning should be given.
~# chage -W 2 root
~# chage -l root
Last password change : Aug 18, 2021
Password expires : Sep 02, 2021
Password inactive : Sep 07, 2021
Account expires : Aug 31, 2021
Minimum number of days between password change : 5
Maximum number of days between password change : 15
Number of days of warning before password expires : 2

