This post describes steps you can take to force users to change passwords at the next login in Ubuntu Linux.
Forcing users to change their passwords at the next login in Ubuntu Linux is a recommended security practice. It ensures that passwords are regularly updated, reducing the risk of unauthorized access to the system or user accounts.
This is especially important in environments where multiple users share a system or where sensitive data is stored. By expiring passwords and forcing users to create new ones, the system administrator can improve system security and reduce the risk of a data breach or security incident.
Force the new user to change their password at the next login in Ubuntu Linux
As described above, you can force new users to change their passwords using the desktop at the next login. If the account already exists, you will have to expire the account to force a password change.
So, create a new user account by selecting the System menu -> Settings -> Users panel.
Click the Unlock button at the top right corner to create a new account or change existing accounts.

On the Add User window, please select the option to Allow users to set a password when they next log in, as highlighted below.

This option will allow the user to set a new password when they try to log in the next time.
Force the existing user to change their password
To force existing users to change their passwords at the next login, you’ll have to expire their account using the passwd command.
To do that, run the commands below:
sudo passwd --expire johndoe
Replace Johndoe with the user account on the system. The subsequent login attempt by the user will be prompted to change it. The user must know the expired password to be allowed to change it.
You can also use the change 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 automatically expires and will be prompted to change at the next login.
sudo charge --lastday 0
johndoe
This will force the user to change their password at the next login.

That should do it!
Conclusion:
This post showed you how to force a user to change their password at the next login in Ubuntu Linux. Please use the comment form below if you find any errors above or have something to add.
Leave a Reply