DebugFactor.com | Forum

How to force user to change password on first login in linux

I have to create multiple users for my project and force the users to change the password when they login to the system for the first time.

To create a user in linux,

adduser <yourusername>

E.g.

adduser joe

Now set a temporary password for the user

passwd <yourusername>

E.g.

passwd joe

To force the user to change the password on first login, you can force expire the password of the user by using the same passwd command. Although the passwd command is used to change the password of a user it supports a special flag to force expire the users password.

passwd --expire <yourusername>

E.g.

passwrd --expire joe