[英]Run sudo command with password
sudo
command can be used in the following way sudo
命令可以按以下方式使用
sudo -u <user_name> <command/script>
But I want to know how to include password as I want to avoid the user interactivity. 但是我想知道如何包括密码,因为我想避免用户交互。 Also, as an Admin, I don't want to disable password prompt for sudo commands.
另外,作为管理员,我不想禁用sudo命令的密码提示。 How can I achieve this.
我该如何实现。 I tried
man sudo
, but not of much help. 我尝试了
man sudo
,但没有太大帮助。
You can use the -S
switch that reads password from stdin
, example: 您可以使用
-S
开关从stdin
读取密码,例如:
~$ echo "yourpassword" | sudo -S <command>
Anyway, as @Thrustmaster said, this is not the right way to use sudo
. 无论如何,正如@Thrustmaster所说,这不是使用
sudo
的正确方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.