linux命令之passwd
linux命令passwd是用来设置/更改用户密码
passwd [参数] username
| 参数 | 说明 |
| --stdin | 非交互式密码设置 |
| -l | 停止用户使用 |
| -u | 启用停止的用户 |
| -d | 删除密码 |
- [root@centos79-3 ~]# passwd ztj
- Changing password for user ztj.
- New password:
- BAD PASSWORD: The password is shorter than 8 characters
- Retype new password:
- passwd: all authentication tokens updated successfully.
- [root@centos79-3 ~]#
命令:
passwd ztj
命令:
echo "ztj" | passwd --stdin ztj
- [root@centos79-3 ~]# echo "ztj" | passwd --stdin ztj
- Changing password for user ztj.
- passwd: all authentication tokens updated successfully.
- [root@centos79-3 ~]#
命令:
passwd -l ztj
- [root@centos79-3 ~]# passwd -l ztj
- Locking password for user ztj.
- passwd: Success
- [root@centos79-3 ~]# cat /etc/shadow | grep ztj
- ztj:!!$6$wwjVQCW8$m2NKGYHU8lVDiQKFqUp0YPQ5j4wYsSLE1WFIp2Oi/fXyvdPf5csIQYYh.nEUwSqhnNY2JAc7w1l/p579RaUpR/:19626:0:99999:7:::
- [root@centos79-3 ~]#
-
命令:
passwd -u ztj
- [root@centos79-3 ~]# passwd -u ztj
- Unlocking password for user ztj.
- passwd: Success
- [root@centos79-3 ~]# cat /etc/shadow | grep ztj
- ztj:$6$wwjVQCW8$m2NKGYHU8lVDiQKFqUp0YPQ5j4wYsSLE1WFIp2Oi/fXyvdPf5csIQYYh.nEUwSqhnNY2JAc7w1l/p579RaUpR/:19626:0:99999:7:::
- [root@centos79-3 ~]#
命令:
passwd -d ztj
- [root@centos79-3 ~]# passwd -d ztj
- Removing password for user ztj.
- passwd: Success
- [root@centos79-3 ~]# cat /etc/shadow | grep ztj
- ztj::19626:0:99999:7:::
- [root@centos79-3 ~]#
命令:
passwd --help
OR
man passwd
- [root@centos79-3 ~]# passwd --help
- Usage: passwd [OPTION...] <accountName>
- -k, --keep-tokens keep non-expired authentication tokens
- -d, --delete delete the password for the named account (root only)
- -l, --lock lock the password for the named account (root only)
- -u, --unlock unlock the password for the named account (root only)
- -e, --expire expire the password for the named account (root only)
- -f, --force force operation
- -x, --maximum=DAYS maximum password lifetime (root only)
- -n, --minimum=DAYS minimum password lifetime (root only)
- -w, --warning=DAYS number of days warning users receives before password
- expiration (root only)
- -i, --inactive=DAYS number of days after password expiration when an account
- becomes disabled (root only)
- -S, --status report password status on the named account (root only)
- --stdin read new tokens from stdin (root only)
-
- Help options:
- -?, --help Show this help message
- --usage Display brief usage message
- [root@centos79-3 ~]#