This post describes steps you can take to force users to change password at next logon in Ubuntu Linux.
Like Windows systems, users of Ubuntu Linux can be forced to change their password at next logon. This allows a user to logon with current password and immediately be prompted to change it.
You can only choose this option when creating a new user using the desktop. If the account already exists, you can’t use the desktop to force a user to change password at next login.
For accounts that already exist, you will have to expire the user account using the passwd command, and the steps below will show you how.
How to force new user to change password at next login in Ubuntu Linux
As described above, using the desktop, you can force new users to change their passwords at next login. If the account already exists, then you will have to expire the account to force a password change.
So go and create a new user account by selecting the System menu -> Settings -> Users panel.
Click the Unlock button at the top right corner to allow for you to create a new account or make changes to existing accounts.
On the Add User window, select the option to Allow user to set a password when they next login as highlighted below.
Choosing this option will allow the user to set a new password when they try to login the next time.
How to force existing user to change password
To force existing users to change their passwords at next login, you’ll have to expire their account using the passwd command.
To do that, run the commands below:
sudo passwd --expirejohndoe
Replace johndoe with the user account on the system. The next login attempts by the user, he or she will be prompted to change it. The user must know the password that was expired to be allowed to change it.
You can also use the chage command with the -d or –lastday option which sets the number of days since January 1st, 1970 when the password was last changed.
When you set it to 0, the account is automatically expired and will prompt to change at the next login.
sudo charge --lastday 0 johndoe
This will force the user to change his/her password at the next login.
That should do it!
This post showed you how to force a user to change their password at the next login in Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.