Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am in need of adding root privileges to a bash script which uses sudo; so that whenever we run the script from the terminal; irrespective of the fact that the user is root or not it should not prompt for password. Please help! Doing Run Bash Script as Root did not help.

share|improve this question
What is the exact command that you have written inside your script? – IgnitE Oct 30 '12 at 18:29
sudo convert outfile.jpeg sabily.png – MKJ Oct 31 '12 at 4:25

2 Answers

The best solution would be use visudo (this tool was made for that and will avoid the exposition of root password), I suggest you to dig what are going wrong with that.

As a workaround, you can run this:

echo <password> | sudo -S some-script

(start the command with a space so it won't be saved in bash history).

Regards.

share|improve this answer

Keeping in mind that by doing this you are allowing anyone to run it I believe you need to chmod it by giving it appropriate permission, 0755 should do it.

share|improve this answer
does not work! :( – MKJ Oct 31 '12 at 18:52
@Pascal - While that does allow anyone to execute the script it doesn't elevate the privileges to run as root. – Argusvision Nov 3 '12 at 2:08

Your Answer

 
discard

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.