Force user to change password

How to force users change their passwords upon first login in Linux? How to make sure user changes password at next login time in Linux?

You can force a user to change their password upon first time login to Linux server. You can even force existing users to change their passwords on next login. This is done using chage command in Linux. The chage command will change the user password expiry information.

1. Make user password expired

To force a Unix / Linux user to change password on their next login, first of all the password must have expired and to cause a user’s password to expire, you can use the passwd command

# passwd --expire oracle

2. Make user password expired

We can use the above chage command to expire a user password. The below chage command will make user password expired. Hence, this will force user to provide a new password. Here we are forcing oracle user to change password on next login

# chage -d 0 oracle

The option -d 0 will mark the password expired and hence, user will be forced to change password.

How to check password status

Once you make the user password expired, we can check this by using below chage command

# chage -l oracle

Last password change                                    : password must be changed
Password expires                                        : password must be changed
Password inactive                                       : password must be changed
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7

Was this article helpful?

Related Articles

Leave a Comment