How to force user to change password in Ubuntu Linux

|

|

The post outlines methods for forcing password changes at next login in Ubuntu Linux. For new desktop user accounts, the option is selectable upon creation. Conversely, for existing accounts, users need to execute the “passwd” command which expires the account, compelling an obligatory password change at subsequent login.

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.

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 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.


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



2 responses to “How to force user to change password in Ubuntu Linux”

  1. s raemsh Avatar
    s raemsh

    Thank you

  2. ramesh s Avatar
    ramesh s

    Thank you

Leave a Reply

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

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading