Search code examples
linuxubuntusudosudoers

restart nginx service without sudo


I need to restart the Nginx service without a password attempt.

I find out there is a way with sudoers. so I add blow command in sudoers but it's not working. I have ubuntu 19.4.

anonymous  ALL=(ALL:ALL) NOPASSWD: /usr/sbin/systemctl restart nginx

so sudo systemctl restart nginx must work without any password attempt.


Solution

  • Look for sudo events in /var/log/auth.log.

    Confirm that systemctl is in fact at /usr/sbin/systemctl (it may be in /bin/systemctl).

    Ensure that you are running as user anonymous on this system for the above sudoers to work.