How to Force User to Change Password in Ubuntu Linux

Share

This post describes steps you can take to force users to change passwords at the next login in Ubuntu Linux.

Like Windows systems, users of Ubuntu Linux can be forced to change their password at the next logon. This allows a user to log on with their 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 the password at the 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 the new user to change their password at the next login in Ubuntu Linux

As described above, using the desktop, you can force new users to change their passwords at the 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 you to create a new account or make changes to existing accounts.

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

Choosing this option will allow the user to set a new password when they try to log in the next time.

How to 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 next login attempt 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 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 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.

ubuntu user passwor change

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. If you find any error above or have something to add, please use the comment form below.