Make users change their password periodically in Ubuntu

When a user account is created, the user is asked to either change his default password or set a new one. And, after that we can warn a user about password change. The idea behind is that his password is about to expire in ‘n’ number of days and we have warned him beforehand to take necessary action. To see how we can warn the user about password change. But, merely warning itself won’t suffice in some cases. And, letting users continue with their old passwords after a certain period poses security risk to both users as well as the organization. So, we can make users change their password periodically in Ubuntu.

We can warn them about the password change. And, if no action is taken then expire the old password and prompt the user to enter a new one at next login. And, set the number of days for which the new password is valid. Beyond that threshold all set passwords expire.

For instance, if the user changes his password on September 11, 2022 and the maximum number of days a password is valid – 30 days. Then, the password will expire on October 11, 2022 and user will have to compulsorily change his/her password.

Note: Following operations require superuser privileges. Contact your System Administrator for assistance, if you don’t have the privileges.

Make users change their password periodically in Ubuntu

The two command-line utilities which can help us get the desired outcome are –

    1. chage and,
    2. passwd.

I. Through chage, use the following syntax –

sudo chage -M <days> <username>

For instance, username – abc and number of days the password is valid – 30 days.

sudo chage -M 30 abc

II. Through passwd,

sudo passwd -x <days> <username>

Again, continuing with the above example –

sudo passwd -x 30 abc

Lastly, how to check for information we have just modified? It can be viewed through following command –

sudo chage -l <username>

In case of user – abc

sudo chage -l abc

where, -l is used to view account aging information.

In conclusion, we have covered how to make users change their password periodically in Ubuntu.

Similar Posts