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


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

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

  • sudo su partner -c supervisord? – Rmano Apr 16 '14 at 22:39
  • Sorry I forgot my .conf file, I tried that way and it did not work, I'll edit my question – ocespedes Apr 16 '14 at 22:51
  • @Rmano Had the right idea. sudo su partner -s /bin/bash -c 'supervisord -c ~/supervisord.conf' That is assuming ~/supervisord.conf is in fact in the partner user's home directory. – ptierno Apr 16 '14 at 22:53

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.