Changing Password Expiry Information

Howto change password expiry information

The chage command is used to modify a Linux users password expiry information. The chage command changes the number of days between password changes and the date of the last password change. "chage" may only be used by the "root" user. However, the "chage -l" option that lists your current expiry status can be used by anyone with a valid account.



Chage Command available Options


Below are the options that can be used by the "chage" command.


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, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -l, --list                    show account ageing 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
  -W, --warndays WARN_DAYS      set expiration warning days to WARN_DAYS


Displaying Password Expiry Information for a user



chage -l user


[root@fedsrv01a ~]# chage -l testuser
Last password change					: May 22, 2015
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

The above "chage" example displays password expiry information for the specified user.



Changing Password expiry information interactively



chage user


[root@fedsrv01a ~]# chage testuser
Changing the aging information for testuser
Enter the new value, or press ENTER for the default

	Minimum Password Age [0]: 
	Maximum Password Age [99999]: 30
	Last Password Change (YYYY-MM-DD) [2015-05-22]: 
	Password Expiration Warning [7]: 5
	Password Inactive [-1]: 
	Account Expiration Date (YYYY-MM-DD) [-1]: 

[root@fedsrv01a ~]# chage -l testuser
Last password change					: May 22, 2015
Password expires					: Jun 21, 2015
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 30
Number of days of warning before password expires	: 5


The above "chage" example demonstrates how the "chage" command can be used to interactively change a users information.



Force a user to change their password at next login



chage -d 0 user


[root@fedsrv01a ~]# chage -d 0 testuser

[root@fedsrv01a ~]# chage -l testuser
Last password change					: password must be changed
Password expires					: password must be changed
Password inactive					: password must be changed
Account expires						: never
Minimum number of days between password change		: 0
Maximum number of days between password change		: 30
Number of days of warning before password expires	: 5

The command "chage -d 0 userid is used to force a user to change their password the next time they login.