AlwaysALearner AlwaysALearner -4 years ago 128
Linux Question

Run sudo command with password

command can be used in the following way

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. How can I achieve this. I tried
man sudo
, but not of much help.

Answer Source

You can use the -S switch that reads password from stdin, example:

~$  echo "yourpassword" | sudo -S <command>

Anyway, as @Thrustmaster said, this is not the right way to use sudo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download