使用echo修改linux 系统密码

通过把管道符和passwd命令的--stdin参数相结合,我们可以用一条命令来完成密码重置操作:

[root@root~]# echo "passwd" | passwd --stdin root
Changing password for user root.
passwd: all authentication tokens updated successfully.

注意事项!!!
使用echo 修改密码尽量不要使用感叹号!
因为感叹号!在shell中有特别的含义 叫做事件提示符。
如果特别一定需要使用感叹号作为密码的一部分,就把双引号换成单引号
[root@root~]# echo '!23qweasdf' | passwd --stdin root

猜你喜欢

转载自www.cnblogs.com/aobulaien/p/12713657.html
今日推荐