Change passwords and adjust password aging for local user accounts

img source: http://www.vatsalthakor.com/2015/10/what-is-user-group-permission-how-to.html

Help from the chage command

# chage --help
-d --> set date of last password change to LAST_DAY
-E --> set account expiration date to EXPIRE_DATE
-h --> display this help message and exit
-I --> set password inactive after expiration to INACTIVE
-l --> show account aging information
-m --> set minimum number of days before password change to MIN_DAYS
-M --> set maximim number of days before password change to MAX_DAYS
-R --> directory to chroot into
-W --> set expiration warning days to WARN_DAYS

To see the details of an account:

# chage -l charles
Last password change : Mar 19, 2019
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

To set the Charles account to expire on December 2, 2019:

                     ***before***
# chage -l charles
Last password change : Apr 01, 2019
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

# chage -E 2019-12-02 charles

***after***
# chage -l charles
Last password change : Apr 01, 2019
Password expires : never
Password inactive : never
Account expires : Dec 02, 2019
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

To set the Charles password to expire in 35 days:

# chage -M 35 charles

How to set the Charles password to be inactive for 5 days (after expire):

# chage -I 5 charles

Set the minimum number of days before changing the password :

# chage -m 3 charles
# chage -l charles
Last password change : Apr 01, 2019
Password expires : May 06, 2019
Password inactive : May 11, 2019
Account expires : Dec 02, 2019
Minimum number of days between password change : 3
Maximum number of days between password change : 35
Number of days of warning before password expires : 7

The warning is per defaults set in 7 days, but if you need to change it:

# chage -W 5 charles

To force the user “charles” to change his password in the next login

# chage -d 0 charles

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *