描述:用來修改帳號和密碼的有效期。bash
用法:chage [option] usercode
選項:io
-m:密碼可更改的最小天數。爲零表明任什麼時候候均可以更改密碼。ast
-M:密碼保持有效的最大天數。配置
-w:用戶密碼到期前,提早收到告警信息的天數。file
-E:帳號到期日期,過了今天,此帳號將不可用。密碼
-d:上一次更改的時間im
-I:停滯時期,若是一個密碼已過時這些天,那麼此帳號將不可用。配置文件
-l:列出當前的設置。由非特權用戶來肯定他們的密碼或帳號什麼時候過時。word
實例:
能夠編輯/etc/login.defs來設定幾個參數,設置口令默認就按照參數設定爲準:
[root@share20 ~]# cat /etc/login.defs PASS_MAX_DAYS 99999 PASS_MIN_DAYS 0 PASS_MIN_LEN 5 PASS_WARN_AGE 7
在/etc/default/useradd能夠找到以下2個參數進行設置:
[root@share20 ~]# cat /etc/default/useradd # useradd defaults file GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel CREATE_MAIL_SPOOL=yes
經過修改配置文件,能對以後新建用戶起做用,而目前系統已經存在的用戶,則直接用chage來配置。
[root@share20 ~]# chage -l root Last password change : Jan 15, 2016 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@share20 ~]# chage -M 360 root [root@share20 ~]# chage -l root Last password change : Jan 15, 2016 Password expires : Jan 09, 2017 Password inactive : never Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 360 Number of days of warning before password expires : 7
而後經過以下命令設置密碼失效時間:
[root@share20 ~]# chage -I 5 root [root@share20 ~]# chage -l root Last password change : Jan 15, 2016 Password expires : Jan 09, 2017 Password inactive : Jan 14, 2017 Account expires : never Minimum number of days between password change : 0 Maximum number of days between password change : 360 Number of days of warning before password expires : 7
時間設定爲99999就是永不過時