Q. How can I force my Linux users to change their passwords upon the first login under CentOS / Debian Linux?
A. You can use any one of the following command to change user passwords upon the first login:
[a] usermod command - Modify various user account properties including user password expiry information.
Where,
[b] chage command - Change user password expiry information
Task: Use chage command to force users to chage their password upon first login
Use the following syntax:
chage -d 0 {user-name}
# chage -d 0 tom
- -d 0 : 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. By setting it to zero, you are going to force user to change password upon first login.
Further readings:
- man pages usermod and chage
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop










{ 6 comments… read them below or add one }
Very useful tip!
I’ll use it.
Excellent tip for livecds… Thanks!!
Great …….. Very Useful
Task: Use chage command to force users to chage their password upon first login
Use the following syntax:
chage -d 0 {user-name}
# chage -d 0 tom
Hello out there! Must be something wrong with the spelling (chage)??
RRRolle, there is nothing wrong with the spelling. ‘chage’ is correct. You are changing the aging attributes of the account — when the password expires, how long between required password changes, etc. chage -l will give this information:
# chage -l nagios
Last password change : Sep 17, 2010
Password expires : Nov 16, 2010
Password inactive : never
Account expires : never
Minimum number of days between password change : 1
Maximum number of days between password change : 60
Number of days of warning before password expires : 7
Hi,
I am a new Linux user and I created users and set their password to expire and force them to change password on their first log in, I tried on one user ,it prompted me to enter current password and when i typed current password the screen usually sleeps. Can anyone advise?