Mailinglist Archive: opensuse (936 mails)

< Previous Next >
Re: [opensuse] Run command as another user
On 09/28/2017 10:34 AM, Paul Groves wrote:

I need to be able to run a command as another user.

I have worked out that I can run the following from one user to
execute a command as the other (bob).

su - bob -c command
prompt for password
enter password

command runs as bob

but, how can I run this on one line for use in a script? (so that I am
not prompted for a password).
something like; su - bob -c command -p bobspassword

The user executing the script is not a sudoer so I cannot use; echo
bobspassword | sudo -S -u bob command

You can use sudo. I have used it for a couple of things. I created a
directory where all the scripts get the root rights and then call the

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
List Navigation
Follow Ups