一直不太明白chage -m参数的意思,从网上搜索也是没有搜到太好的例子,只是说明-m参数的功能,本人也不是太明白解释的意思:
-m --mindays MIN_DAYS
Set the minimum number of days between password changes to MIN_DAYS.
A value of zero for this field indicates that the user may change
his/her password at any time.
-m:中文解释的意思:密码可更改的最小天数。为零时代表任何时候都可以更改密码
后来看到鸟哥的LINUX私房菜中的解决,才有些明白:-m 密码最短保留天数
经过测试最终明白了-m参数的意思:密码最短保留天数,此天数之内不能对密码进行修改,说直白一些就是从上次密码修改的日期+这个天数之内的日期不能修改密码,当用户尝试修改密码时,会提示如下信息:
You must wait longer to change your password
passwd: Authentication token manipulation error
root用户直接修改用户密码不受影响
例子如下:
test用户的密码过期策略如下,默认值:
[root@desktop ~]# chage -l test
Last password change : Jun 10, 2014
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
系统日期如下:
[root@desktop ~]# date
Thu Jun 12 00:37:14 CST 2014
修改Minimum number of days between password change值:
[root@desktop ~]# chage -m 2 test
[root@desktop ~]# chage -l test
Last password change : Jun 10, 2014
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 2
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
切换test用户,修改密码,会报如下错误:
[root@desktop ~]# su - test
[test@desktop ~]$ passwd
Changing password for user test.
Changing password for test.
(current) UNIX password:
You must wait longer to change your password
passwd: Authentication token manipulation error
报如上错误的原因是由于密码保留的最短天数还没有到,即上次修改密码时间为2014年6月10日,密码最短保留天数为2天,则密码保留到2014年6月12日,此时间之内,密码不能修改,而到了2014年6月13日后,就可以修改密码
继续测试:修改系统时间为2014年6月13日,显示修改后的日期:
[test@desktop ~]$ date
Fri Jun 13 00:45:56 CST 2014
再次修改密码,成功:
[test@desktop ~]$ passwd
Changing password for user test.
Changing password for test.
(current) UNIX password:
New password:
Retype new password:
passwd: all authentication tokens updated successfully.