Linux(CentOS)用戶修改密碼有效期(chage命令)

Linux設置用戶密碼的有效期限bash

 

解決:

        先查看密碼過時時間,如今是90天   spa

1
2
3
4
5
6
7
8
[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

  

  用命令修改過時時間爲永久,而後查看Password expires   : never   和  Maximum number of days between password change  : 99999修改爲功code

1
2
3
4
5
6
7
8
9
[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

 補充知識=================== chage命令用法:  ================================================blog

 
複製代碼
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
相關文章
相關標籤/搜索