ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

echo “新密码”|passwd --stdin 用户名

2026/8/15 7:14:54 拓冰建站 浏览量
echo “新密码”|passwd --stdin 用户名 --stdinThis option is used to indicate that passwd should read the new password from standard input, which can be a pipe.这个选项用于从标准输入管道读入新的密码。使用 echo 方式来重置Linux 系统用户密码echo “新密码”|passwd --stdin 用户名12345678910[rootrhel7 ~]# passwd --stdin rusky 为rusky用户设置密码。Changing passwordforuser rusky.zxcvbnmpasswd: all authentication tokens updated successfully.[rootrhel7 ~]# echoqwertqwert[rootrhel7 ~]# echoqwert| passwd --stdin rusky 把echo返回的字符qwert设置为用户rusky的密码Changing passwordforuser rusky.passwd: all authentication tokens updated successfully.[rootrhel7 ~]#这种方式虽然简单但是通过history命令可以查到用户的密码所以不安全。