Force Linux Password Change on Next Login

Posted by Grego on September 12, 2016

To force a linux user to change their password on next login

Using chage:

sudo chage -d 0 USERNAME

Replace USERNAME with the actual user login. The -d option will set the last time that the password was updated to the unix epoch (January 1, 1970) which will automatically cause the password to expire.

More on chage:

The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.

   -d, --lastday LAST_DAY
       Set the number of days since January 1st, 1970 when the password was last changed. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area).

Using passwd:

If you want to set a user’s password and expire it at the same time:

sudo passwd -e USERNAME

Note: not all versions of passwd will have the -e switch, but I have seen it for sure on Ubuntu.