4

I want a script X.sh to switch users and perform an action, but so far I have this:

 #!/bin/sh

 sudo su partner -s /bin/bash 
 supervisord -c ~/supervisord.conf
exit

I want that the user partner execute supervisord and exit, but all I get is a switched user in the comand line a bash shell, doing the su partner -s /bin/bash is the only way in which I can access the partner user.

Please Help

ocespedes
  • 165

1 Answers1

5

You should use sudo -u partner supervisord -C ~/supervisord.conf instead, and set up your current user in the /etc/sudoers file. An entry to allow user "current" to execute this command as "partner" would look something like this:

current ALL=(partner:partner) NOPASSWD: /path/to/supervisord

Make sure and use visudo instead of trying to edit the sudoers file manually. There is a more in-depth but simple explanation of the sudoers file syntax here.

jkt123
  • 3,600