Quote:
While creating user , i can set password expiry date.
how can i put it to all existing users in linux?
Question is => how can i set already existing users ?
ex : existing user is sam
|
You can use
chage command to set password expiry date to all users.
Check the password aging policy(PAP) for sam user using
For example if you want to set password aging to this user as minimum 0 days maximum 90 days and warn before 7 days, run
Code:
chage -m 0 -M 90 -W 7 sam
Now check whether or not PAP is set to this user
Now you will find output something like below
Code:
Last password change : Oct 15, 2012
Password expires : Jan 13, 2013
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 90
Number of days of warning before password expires : 7
The same way you can use for all users. Or even you can set PAP for all users simultaneously using single command
Code:
for i in $(awk -F':' '/\/home.*sh/ { print $1 }' /etc/passwd); do chage -m 0 -M 90 -W 7 $i; done
But before that make sure the users that you are going to set PAP to, using
Code:
for i in $(awk -F':' '/\/home.*sh/ { print $1 }' /etc/passwd); do echo $i; done
For more information
To apply PAP automatically for new users you have to edit /etc/login.defs file and there you will find something like below
Code:
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_WARN_AGE 7
change this to
Code:
PASS_MAX_DAYS 90
PASS_MIN_DAYS 0
PASS_WARN_AGE 7