我想使用su在一个命令行中更改用户
echo password | su user但这是行不通的。还有其他的可能性吗?谨致问候
发布于 2012-04-26 19:39:33
首先:问问自己,脚本是否真的有必要知道密码。sudo和SE-Linux通常会为您提供大量的选项,以避免输入密码。
也就是说,su打开它的控制终端来读取密码,而不是标准输入。您可以使用带有-S选项的sudo从标准输入中读取密码。
发布于 2012-04-26 19:42:46
摘自sudo的手册:
-S
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character. 发布于 2012-04-26 19:36:42
做下面的事..
passwd root,它将要求您输入新密码,然后您以管理员身份登录并执行您想要的操作
https://stackoverflow.com/questions/10332544
复制相似问题