一天一个Linux命令--chage

介绍

chage命令是用来修改账号和密码的有效期限

使用语法

1
chage [选项] 用户名

选项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//设置最后改密码的日期
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
//设置账号有效期的最终日期
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
//使账号失效
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
//查看账号有效期信息
-l, --list show account aging information
//设置修改密码的最小间隔天数,0表示可以随时修改密码
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
//设置密码有效的最长天数, 99999表示永久有效
-M, --maxdays MAX_DAYS set maximim number of days before password
change to MAX_DAYS
//设置密码过期前开始提示警告的天数
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS

示例

1
[huanghe@huanghe_centos ~]$ chage -l huanghe

表示查询用户huanghe的有效期信息

1
2
3
4
5
6
7
Last password change : Mar 14, 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

1
[huanghe@huanghe_centos ~]$ chage -M 99999 huanghe //将用户huanghe有效期改为永久