1、 先查看密碼過期時間:
[root@01 ~]# chage -l testuser Last password change : Jul 10, 2017 Password expires : Oct 08, 2018 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 : 10
2、用命令修改過期時間為永久,然后查看Password expires : never 和 Maximum number of days between password change : 99999修改成功
[root@01 ~]# chage -M 99999 testuser [root@01 ~]# chage -l testuser Last password change : Jul 10, 2017 Password expires : never Password inactive : never Account expires : Oct 16, 2243 Minimum number of days between password change : 0 Maximum number of days between password change : 99999 Number of days of warning before password expires : 10
3、補充知識=================== chage命令用法:
chage:密碼失效是通過此命令來管理的。 參數意思: -m 密碼可更改的最小天數。為零時代表任何時候都可以更改密碼。 -M 密碼保持有效的最大天數。 -W 用戶密碼到期前,提前收到警告信息的天數。 -E 帳號到期的日期。過了這天,此帳號將不可用。 -d 上一次更改的日期 -I 停滯時期。如果一個密碼已過期這些天,那么此帳號將不可用。 -l 例出當前的設置。由非特權用戶來確定他們的密碼或帳號何時過期。
[root@localhost ~]# chage -l test #查看用戶密碼設定情況 最近一次密碼修改時間 : 4月 27, 2018 密碼過期時間 : 從不 密碼失效時間 : 從不 帳戶過期時間 : 從不 兩次改變密碼之間相距的最小天數 :-1 兩次改變密碼之間相距的最大天數 :-1 在密碼過期之前警告的天數 :-1 [root@localhost ~]# chage -M 90 test #密碼有效期90天 [root@localhost ~]# chage -d 0 test #強制用戶登陸時修改口令 [root@localhost ~]# chage -d 0 -m 0 -M 90 -W 15 test #強制用戶下次登陸時修改密碼,並且設置密碼最低有效期0和最高有限期90,提前15天發警報提示 [root@localhost ~]# chage -E '2014-09-30' test # test這個賬號的有效期是2014-09-30