Restart/Stop Nginx using my UserId without sudo permissions

一曲冷凌霜 提交于 2020-01-16 19:47:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!