您的位置:首页 > 运维架构 > Linux

Linux用户和组的操作(九) 修改用户账号密码时间参数 chage

2013-03-12 17:42 661 查看
使用chage(change age)命令也可以修改用户账号密码的时间参数,而且可以直观显示。
chage命令行选项:

选项[/b]

含义[/b]
-l [/b]
列出用户账号密码的详细时间参数[/b]
-d [/b]
修改密码修改日期,/etc/shadow中第三字段,为0表示第一次登陆强制修改密码
-m [/b]
修改密码冻结天数,/etc/shadow中第四字段
-M[/b]
修改密码有效天数,/etc/shadow中第五字段
-W[/b]
修改密码警告天数,/etc/shadow中第六字段
-I[/b]
修改密码宽限天数,/etc/shadow中第七字段,为-1表示不会失效
-E[/b]
修改账号失效日期,/etc/shadow中第八字段
[root@localhost ~]# chage -d 2013-03-01 -m 5 -M 180 -W 7 -I 10 -E 2013-12-30 stone
#修改stone的账号密码时间参数
[root@localhost ~]# chage -l stone
Last password change : Mar 01, 2013
Password expires : Aug 28, 2013
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
Number of days of warning before password expires : 7
#列出stone的账号时间参数

[root@localhost ~]# chage stone
Changing the aging information for stone
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
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:
#第一次登陆提示用户修改密码,参考了《鸟哥私房菜》。
本文出自 “石头记” 博客,请务必保留此出处http://stonebox.blog.51cto.com/5409313/1152713
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: