问题
I need to restart the nginx services installed via root using my user-id ie TAG1 without the help of sudo. Now we are using the below command to restart the Services
**COmmand : sudo /usr/bin/systemctl restart nginx**
So please provide us with some inputs how to restart nginx services using a newid without using SUDO permissions.
回答1:
Answer: Using visudo, add the following to your sudoers file, replacing username with the proper username
USER ALL = NOPASSWD: /usr/bin/systemctl restart nginx
This will allow the user to run "/usr/bin/systemctl restart nginx" with any or zero following attributes (ie. start|stop|restart).
References for more detail:
https://askubuntu.com/questions/692701/allowing-user-to-run-systemctl-systemd-services-without-password
https://serverfault.com/questions/69847/linux-how-to-give-a-user-permission-to-restart-apache
来源:https://stackoverflow.com/questions/51019993/restart-stop-nginx-using-my-userid-without-sudo-permissions