Table of Contents
This tip is about the how to Force User to Change Password at Next Login in Linux. So read this free guide, How to Force User to Change Password at Next Login in Linux step by step. If you have query related to same article you may contact us.
How to Force User to Change Password at Next Login in Linux – Guide
How can I force my Linux users to change their passwords on first login on a CentOS/Debian Linux? How to ensure user changes passphrase on next login to Linux server? You can use any of the accompanying prompts to change user passwords on first login:
Force user to change password using passwd command
The passwd command is primarily used to assign or change a user’s password on a Linux system. For example, to reset the password of a user named bob, simply run the command below as the root user:
bob passwd
You will be prompted for a new password for the user account and later to confirm it as shown. In addition to setting or changing a user’s password, the passwd command can also be used to force the user to change their password the next time they try to log in. This is possible using the syntax provided.
passwd -e [username]
The -e option (also expressed as –expire) simply expires the user’s account password and forces the user to change the password at the next login. For example, to remove bob’s password, just run the command
passwd -e bob
OR
passwd — expires bob
After that, you can check the password expiration or expiration information by running the chage command as shown.
chage -l bob
From the output we can clearly see that the password of user bob needs to be changed at the next login. On the next login attempt, user bob will receive a notification that their password has expired and must be changed before proceeding. The user must first provide the previously used password, then enter the new password and confirm it as shown below.
Force user to change password using chage command
As we did earlier, the chage command provides information about user aging information. You can also use the command to expire a user’s password and force them to change it at the next login.
You can achieve this by using the -d option followed by 0, which implies day zeo. Also, you can use the –lastday flag that specifies the number of days since the epoch (January 1, 1970). The syntaxes are given below
change -d 0 [username]
OR
chage –lastday 1970-01-01 [username]
For example, you can expire a user named jack, as shown.
chage -d 0 jack
Final note
I hope you like the guide How to Force User to Change Password at Next Login in Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.