How to Force Password Changes for Users in Linux: 2 Quick Ways

Are you tired of weak passwords and want to boost Linux security?

Let’s learn how to force user password changes and keep your system safe. It reduces the risk of a compromised password for a long period.

This guide will demonstrate two easy ways to force a password change for users in Linux.

How to Force Password Changes for Users in Linux?

To keep your Linux system secure with strong unique passwords, two effective methods to enforce password changes for users in your Linux system are discussed below:

1. Using the “passwd” Command

passwd” is a versatile command that is primarily utilized to update a user’s password.

For instance, you can access your Linux terminal with root privileges (with sudo -i or sudo su). Then, run the “passwd” command, replacing username with the actual username of the target user:

sudo su
passwd -e <username>

By using the -e or –expire flag with passwd, you can expire the user’s password, forcing them to change it on their next login:

Force Password Changes for Users in Linux using the passwd Command

Note: The user prompts an interface to set a new password upon their next login.

2. Using the “chage” Command

Another powerful command is chage which allows for more control over password expiration and aging policies. This command allows you to manage password-aging settings for user accounts.

For instance, first access the terminal with root privileges. Then, run the chage command by replacing “username” with the target user as below:

sudo su
chage -d 0 <username>

Here, the -d 0 flag sets the minimum days before password change to 0, forcing the user to change it on their next login:

Force Password Changes for Users in Linux using the chage Command

Conclusion

To force a password change for users in Linux, you can use the passwd command with the –expire option. Alternatively, you can also use the chage command with the –d 0 option to achieve the same result.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top