How can I grant a user access to run /etc/init.d/apache2 reload without giving them sudo or root?
-
Another basic Ubuntu (10.4) question: I'm using automated deployment scripts to roll out changes to my site (written using Fabric, running over SSH with public key authentication). At the moment the end of each script does a "sudo /etc/init.d/apache2 reload" and I often have to enter my password. How can I grant the user account used by my deployment scripts permission to run that one command using sudo without letting the account do anything else?
-
Answer:
Use NOPASSWD tag and allow execution of only single command (including reload parameter) necessary. Read sudo manual carefully: http://www.sudo.ws/sudo/sudoers.man.html and you'll discover many possibilities. I'd recommend you to get acquainted with ServerFault as it has complete answer to your exact question: http://serverfault.com/questions/69847/linux-how-to-give-a-user-permission-to-restart-apache/69854#69854
Myroslav Opyr at Quora Visit the source
Other answers
add your command in /etc/sudoers file. Add following line in your /etc/sudoers file to give the permission, save and exit from it. userName ALL=/etc/init.d/apache2 reload where username is for which user you want to give the permission. Now login with given userName and run the command with sudo. http://viewsby.wordpress.com/2012/11/20/allow-normal-user-to-run-some-commands-as-root-linux/
Sandeep Reddy
Apache should be reloaded when you change its configuration, or when it eats too much RAM (and there are automatic systems to do this). Why you should reload it when you deploy websites?
Giovanni Cappellini
Related Q & A:
- How can I find a Yahoo user ID if I only have the name?Best solution by Yahoo! Answers
- How can I insert a picture in Email without attaching it?Best solution by Super User
- How can I get a loan without a job?Best solution by Yahoo! Answers
- How can I connect a printer wirelessly to my laptop without a router? Which printer would be the best?Best solution by Yahoo! Answers
- How can I send a message to yahoo groups without requiring the approval of the moderators?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.