How to force users to change their password upon first login?
In this tutorial we will force a new user to change the password upon first login. This is usually used by sysadmins. We will use a linux command 'chage' - which will change user password expiry information.
The chage command changes the number of days between password changes and the date of the last password change. This information is used by the system to determine when a user must change his/her password.
First lets start by creating a user "chia"
[root]# useradd chia
Setup a password for chia
[root]# passwd chia
Now, we will change the password expiry date to 0 so that the user "chia" will be forced to change the password on login.
[root]# chage -d 0 chia
If you read the man page of the command "chage", -d <days> means
Set the number of <days> since January 1st, 1970 when the password was last changed. The date may also be expressed in the format YYYY-MM-DD (or the format more commonly used in your area).
By using 0, we will automaticaly expire the passwd, forcing user to change it on first login.
Now when you login using chia
You are required to change your password immediately (root enforced)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user chia.
Changing password for chia.
(current) UNIX password:
How to force every new user to change password at first login
For this change we need to change the default setting of useradd command.
[root]# vim /etc/default/useradd
Look for the line or just append the following line in the file.
Expire=0
How to force user to change password at first login in GUI
The same method works for GUI logins too. I have tried it on Ubuntu.






, but in case you have to, then ImageMagick will make this job really easy for you. ImageMagick is a great opensource command line utility for image manipulation.





















Post new comment