Allow a user to run specific sudo command only

Issue

  • I need to give permission to my develper to specific sudo command only.
  • I need to give permission to restart apache httpd service.

Versions

  • Any Linux Flavour. CentOS, RHEL, Ubuntu , SuSE etc

Solution

  • run visudo to get the sudo access editor.
  • add the below line to the file and save and exit
mydeveloper ALL=(ALL) NOPASSWD: /etc/init.d/httpd *
  • Now the devloper can run the below command to stop, start, restart httpd services `sudo /etc/init.d/httpd start sudo /etc/init.d/httpd stop sudo /etc/init.d/httpd restart`

Note

If you want to give the same access to a group of people,

  • Add those to a group.
gpasswd -a dev1 mydevelopergroup
gpasswd -a dev2 mydevelopergroup 
gpasswd -a dev3 mydevelopergroup 
  • Add the the below line to visudo
%mydevelopergroup ALL=(ALL) NOPASSWD: /etc/init.d/httpd *

Like / share / + / Tweat if found helpfull 🙂

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top