How to Force User to Change Password in Ubuntu Linux

programmer 1653351 640
programmer 1653351 640

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 users to log on with their current password and immediately be prompted to change it.

You can only choose this option when creating a new desktop user. If the account already exists, you can’t use the desktop to force a user to change the password at the next login.

You will have to expire the user account using the passwd command for already existing accounts, 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, 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.

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 subsequent login attempt by the user, they 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 prompt change at the next login.

sudo charge --lastday 0 johndoe

This will force the user to change their 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. Please use the comment form below if you find any errors above or have something to add.

Posted by
Richard

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

2 Comments

  1. Thank you

  2. Thank you

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: