Options:
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, --help display this help message and exit
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --list show account aging information
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, --maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
-R, --root CHROOT_DIR directory to chroot into
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
[root@node2 ~ ]#
查看root用户密码过期时间
[root@node2 ~ ]# chage -l root
Last password change : never
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@node2 ~ ]# chage -d 0 -m 0 -M 180 -W 15 root 设置密码最低有效期0-180天,提前15天发警报提醒
[root@node2 ~ ]# chage -l root
Last password change : Jun 20, 2019 最近一次密码更改:2019年6月20日
Password expires : Dec 17, 2019 密码过期:2019年12月17日
Password inactive : never 密码无效:从未
Account expires : never 帐户过期:从未
Minimum number of days between password change : 0 密码更改之间的最短天数:0
Maximum number of days between password change : 180 密码更改之间的最大天数:180天
Number of days of warning before password expires : 15 密码过期前的警告天数:15天
[root@node2 ~ ]#
如果设置完查看是:密码必须修改,哪么就要重置密码进行生效
重置密码让密码使用期限策略生效:
[root@node2 ~ ]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node2 ~ ]#
[root@node2 ~ ]#
[root@node2 ~ ]# chage -l root
Last password change : Jun 24, 2019
Password expires : Jun 26, 2019
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 2
Number of days of warning before password expires : 1
[root@node2 ~ ]#
[root@node1 ~ 14:03:31]# chage -l aihuidi
Last password change : Jul 08, 2019
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
Last password change: 表示账号创建时的时间
Account expires: 表示账号到期时间
[root@node1 ~ 14:07:09]# chage -l aihuidi
Last password change : Jul 08, 2019
Password expires : never
Password inactive : never
Account expires : Jul 10, 2019
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@node1 ~ 14:07:13]#