修改用户密码状态
- 直接修改文件(建议使用这种方法,更加直观)
- 使用命令修改
1. 命令格式
chage [选项] 用户名
[root@VM-0-7-centos ~]# chage --help
Usage: chage [options] LOGIN
Options:
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-h, --help display this help message and exit
-I, --inactive INACTIVE set password inactive after expiration
to INACTIVE
-l, --list show account aging information
-m, --mindays MIN_DAYS set minimum number of days before password
change to MIN_DAYS
-M, --maxdays MAX_DAYS set maximum number of days before password
change to MAX_DAYS
-R, --root CHROOT_DIR directory to chroot into
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
[root@localhost ~]#chage [选项] 用户名
选项:
-l: 列出用户的详细密码状态
-d 日期: 密码最后一次修改日期(/etc/shadow文件的第三个字段),格式为YYYY-MM-DD
-m 天数: 密码的两次修改间隔时间(第四个字段)
-M 天数: 密码的有效期(第五个字段)
-W 天数: 密码修改到期前的警告天数(第六个字段)
-I 天数: 密码过期后的宽限天数(第七个字段)
-E 日期: 账号失效时间(第八个字段),格式为YYYY-MM-DD
通过chage命令可以查看和修改/etc/shadow文件的第三个字段到第八个字段的密码状态。
[root@VM-0-7-centos ~]# chage -l handsome
Last password change : Aug 19, 2021
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