Setting user Specific password policy:
One option is to modify user password policy - using
Below command will set minimum number of days required between pasword changes.
lchage --mindays=<days> <username>
Below command can be used to see current policy
lchage --list <username>
Common Policy for All users:
To set password policy common for all users in system, you need to edit
PASS_MIN_DAYS variable in
root@ubuntu:~# grep PASS_MIN_DAYS /etc/login.defs
# PASS_MIN_DAYS Minimum number of days allowed between password changes.
Above grep listing shows minimum # days required between password changes is 1.
If user tries to reset password before minimum # days set, he/she will get error as listed below.
Changing password for test.
(current) UNIX password:
You must wait longer to change your password
passwd: Authentication token manipulation error
passwd: password unchanged
While creating user, policy defined in
/etc/login.defs will be applicable to user being created. Again
lchage --list command can be used to see current policy.