命令介紹
命令:chage 管理用戶密碼時效問題
用法:chage [options] LOGIN chage 用戶
命令選項
[root@fp-21 ~]# chage
-d, --lastday LAST_DAY # 指定日期爲最近一次密碼修改時間
-E, --expiredate EXPIRE_DATE # 指定日期爲用戶密碼過期時間
-h, --help # 幫助文檔
-I, --inactive INACTIVE # 密碼過期後,設置爲失效
-l, --list # 顯示用戶密碼信息
-m, --mindays MIN_DAYS # 設置兩次更改密碼之間的最短天數
-M, --maxdays MAX_DAYS # 設置兩次更改密碼之間的最長天數
-W, --warndays WARN_DAYS # 設置密碼失效前的警告天數
命令實例
# 指定日期爲最近一次密碼修改時間
[root@fp-21 ~]# chage -d 2020/2/15 tom
[root@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
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@fp-21 ~]# chage -E 2020/2/20 tom
[root@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
Password expires : never
Password inactive : never
Account expires : Feb 20, 2020
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@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
Password expires : never
Password inactive : never
Account expires : Feb 20, 2020
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@fp-21 ~]# chage -m 1 tom
[root@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
Password expires : never
Password inactive : never
Account expires : Feb 20, 2020
Minimum number of days between password change : 1
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
# 設置兩次更改密碼之間的最長天數
[root@fp-21 ~]# chage -M 10 tom
[root@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
Password expires : Feb 25, 2020
Password inactive : never
Account expires : Feb 20, 2020
Minimum number of days between password change : 1
Maximum number of days between password change : 10
Number of days of warning before password expires : 7
# 設置密碼失效前的警告天數
[root@fp-21 ~]# chage -W 3 tom
[root@fp-21 ~]# chage -l tom
Last password change : Feb 15, 2020
Password expires : Feb 25, 2020
Password inactive : never
Account expires : Feb 20, 2020
Minimum number of days between password change : 1
Maximum number of days between password change : 10
Number of days of warning before password expires : 3