使用chage(change age)命令也可以修改用户账号密码的时间参数,而且可以直观显示。
chage命令行选项:
选项
linux修改文件所属用户和组、含义
-l
列出用户账号密码的详细时间参数
-d
linux修改用户组和用户?修改密码修改日期,/etc/shadow中第三字段,为0表示第一次登陆强制修改密码
-m
修改密码冻结天数,/etc/shadow中第四字段
-M
linux更改组用户的权限?修改密码有效天数,/etc/shadow中第五字段
-W
修改密码警告天数,/etc/shadow中第六字段
-I
linux建立用户组,修改密码宽限天数,/etc/shadow中第七字段,为-1表示不会失效
-E
修改账号失效日期,/etc/shadow中第八字段
[root@localhost ~]# chage -d 2013-03-01 -m 5 -M 180 -W 7 -I 10 -E 2013-12-30 stone
centos7修改用户密码、#修改stone的账号密码时间参数
[root@localhost ~]# chage -l stone
Last password change: Mar 01, 2013
Password expires: Aug 28, 2013
linux 用户加入组。Password inactive: Sep 07, 2013
Account expires: Dec 30, 2013
Minimum number of days between password change: 5
Maximum number of days between password change: 180
centos修改用户密码命令。Number of days of warning before password expires: 7
#列出stone的账号时间参数
[root@localhost ~]# chage stone
Changing the aging information for stone
centos默认用户名密码、Enter the new value, or press ENTER for the default
Minimum Password Age [5]: 6
Maximum Password Age [180]: 150
Last Password Change (YYYY-MM-DD) [2013-03-01]: 2013-3-10
linux修改组id?Password Expiration Warning [7]: 5
Password Inactive [10]: 7
Account Expiration Date (YYYY-MM-DD) [2013-12-30]: 2013-10-1
#不使用命令选项直接加用户名,可交互修改账户时间参数
[root@localhost ~]# chage -l stone
Last password change: Mar 10, 2013
Password expires: Aug 07, 2013
Password inactive: Aug 14, 2013
Account expires: Oct 01, 2013
Minimum number of days between password change: 6
Maximum number of days between password change: 150
Number of days of warning before password expires: 5
[root@localhost ~]# useradd agetest
[root@localhost ~]# echo "agetest" | passwd --stdin agetest
Changing password for user agetest.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# chage -d 0 agetest
#新建用户agetest,并将密码设置为agetest,设置密码修改日期为0。
[root@localhost ~]# su – stone
#切换用户
[stone@localhost ~]$ su - agetest
Password:
You are required to change your password immediately (root enforced)
Changing password for agetest
(current) UNIX password:
New UNIX password:
Retype new UNIX password:
#第一次登陆提示用户修改密码,参考了《鸟哥私房菜》。
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态