Manage password expiry on Linux

tux_compUsers tend not to change their passwords often due to the apparent inconvenience caused. However, in a multi-user environment, it is preferred that users change their passwords regularly. This also applies if the admin wants users to change their password on their very first login, i.e., immediately after their account details are handed over to them.

To setup a password expiry policy, e.g., to force password expiry every 15 days, run:

$ sudo passwd -n 15 username

To check how many days left to password expiry:

$ sudo chage -l username
Last password change					: Oct 01, 2015
Password expires					: never
Password inactive					: never
Account expires						: never
Minimum number of days between password change		: 15
Maximum number of days between password change		: 99999
Number of days of warning before password expires	: 7

To allow the user change his password any time (default behaviour), i.e., no enforcement, run:

$ sudo passwd -n 0 username

To force a password resent on next login, run:

$ sudo chage -d0 username
// OR
$ sudo passwd -e username

Leave a Reply

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