Use sudo or sudoers to start, stop & restart Apache
Q. I am responsible for 5 Apache webservers. Recently we hired a new Linux sys admin. How do I give new admin only permission to start and restart Apache web server? How do I setup sudo for the same via sudoers file? I am using RedHat Enterprise Linux.
A. sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file. The real and effective uid and gid are set to match those of the target user as specified in the passwd file and the group vector is initialized based on the group file.
sudo is great way to avoid security problems. sudo requires that users authenticate themselves with a password by default. sudo also logs user command is log file.
Use visudo command to setup job for a new sys admin called jerry, so that user can start or stop Apache webserver:
# visudo
Append following line:
vivek hostname=/etc/init.d/httpd start, /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd restart
Save and close the file. Jerry has to type following command:
$ sudo /etc/init.d/httpd restart
When prompted jerry need to provide his password. More information is regarding sudo is available here.
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Ubuntu Linux Start / Restart / Stop Apache Web Server
- Ubuntu Linux: Start / stop / restart OpenSSH / ssh server
- How To Start and Stop MySQL Database Server From A Shell Prompt
- Linux Start and stop the cron or crond service
- Ubuntu Linux restart network
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!


December 2nd, 2006 at 11:48 pm
Sudo is kind of the standard in this area, but here are a few others that might be of interest to people:
calife
chiark-really
That said, I use sudo.