-d:删除密码,仅有系统管理者才能使用;
-f:强制执行;
-k:设置只有在密码过期失效后,方能更新;
-l:锁住密码;
-s:列出密码的相关信息,仅有系统管理者才能使用;
-u:解开已上锁的帐号。
例如:jack:X:503:504:::/home/jack/:/bin/bash
jack //用户名
X //口令、密码
503 //用户id(0代表root、普通新建用户从500开始)
504 //所在组
: //描述
/home/jack/ //用户主目录
/bin/bash //用户缺省Shell
例如:jack:$!$:???:13801:0:99999:7:*:*:
jack //组名
$!$ //被加密的口令
13801 //创建日期与今天相隔的天数
0 //口令最短位数
99999 //用户口令
7 //到7天时提醒
* //禁用天数
* //过期天数
[root@localhost ~]# passwd linuxde //更改或创建linuxde用户的密码;
Changing password for user linuxde.
New UNIX password: //请输入新密码;
Retype new UNIX password: //再输入一次;
passwd: all authentication tokens updated successfully. //成功;
[linuxde@localhost ~]$ passwd
Changing password for user linuxde. //更改linuxde用户的密码;
(current) UNIX password: //请输入当前密码;
New UNIX password: //请输入新密码;
Retype new UNIX password: //确认新密码;
passwd: all authentication tokens updated successfully. //更改成功;
[root@localhost ~]# passwd -l linuxde //锁定用户linuxde不能更改密码;
Locking password for user linuxde.
passwd: Success //锁定成功;
[linuxde@localhost ~]# su linuxde //通过su切换到linuxde用户;
[linuxde@localhost ~]$ passwd //linuxde来更改密码;
Changing password for user linuxde.
Changing password for linuxde
(current) UNIX password: //输入linuxde的当前密码;
passwd: Authentication token manipulation error //失败,不能更改密码;
[root@localhost ~]# passwd -d linuxde //清除linuxde用户密码;
Removing password for user linuxde.
passwd: Success //清除成功;
[root@localhost ~]# passwd -S linuxde //查询linuxde用户密码状态;
Empty password. //空密码,也就是没有密码;