passwd命令使用

2018-03-01  10:01:06


例1:passwd username 直接修改用户的密码
普通用户可以且只能修改自己的密码,root用户可以修改任何人的密码
[root@localhost ~]# passwd chen
Changing password for user chen.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.

例2: 明文直接修改用户密码
[root@localhost ~]# echo "afasf" |passwd --stdin chen
Changing password for user chen.
passwd: all authentication tokens updated successfully.

例3:锁定某个用户的密码不能修改(在锁定的情况下,root用户仍然可以修改其密码)
[root@localhost ~]# passwd -l chen
Locking password for user chen.
passwd: Success

[chen@localhost ~]$ passwd
Changing password for user chen.
Changing password for chen.
(current) UNIX password:
passwd: Authentication token manipulation error


例4:解锁某个用户,
命令格式:root执行:passwd -u xxx -u:unlock

[root@localhost ~]# passwd -u chen ------------陈的密码保护被解除
Unlocking password for user chen.
passwd: Success
[root@localhost ~]# su - chen

[chen@localhost ~]$ passwd ------------- 此时输入的密码要求:不能太短和字母和数字组合(root下无此要求)
Changing password for user chen.
Changing password for chen.
(current) UNIX password: ------------- 输入当前的密码
New password:
BAD PASSWORD: it does not contain enough DIFFERENT characters
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

原文地址:https://www.cnblogs.com/kaishirenshi/p/8487034.html