Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do not have sudo installed on my machine, but I have a third party program which runs as different user other than root and tries to execute sudo command. Is there a way to enable this program to run sudo ?

I have logged in as root and created sudo bash script in /usr/bin with following contents, since I know root password is there a way I can modify the script to run the command with root privileges. Or is there any other way ? Yes this is foolish, but I need this only for testing.

share|improve this question
You can write a wrapper script that runs ssh root@localhost and run whatever you want. – dawud May 9 '13 at 6:28
@dawud how can I add password to the above command, since sudo script is run by other program which runs in background. – Sirish Kumar May 9 '13 at 6:35
I have tried copying the public key to roots authorized keys file and run the command ssh root@localhost command, it worked fine – Sirish Kumar May 9 '13 at 8:42
Nice to hear. Keep in mind this is not optimal, nor auditable in the way sudo is. – dawud May 9 '13 at 9:29

You seem to be asking about the SUID bit; if you do chown root:root /usr/local/bin/foo; chmod 4755 /usr/local/bin/foo then, in theory, whoever runs /usr/local/bin/foo will run it as root. But the concept is so security-problematic that somes OSes don't honour the SUID bit at all, and others don't honour it on some executables (eg, shell scripts).

Since you have the root password, why not just install sudo? It has a good security track-record, and you can restrict the ability to run as root not just to a certain executable, but to a certain user also.

If you absolutely must use the suid bit, do not grant suid-root status to the script above, or you will have given anyone the power to do anything as root.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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