在没有sudo权限的情况下使用我的UserId重新启动/停止Nginx



我需要在没有sudo帮助的情况下使用我的user-id ie TAG1重新启动通过root安装的nginx服务。现在我们使用以下命令重新启动服务

**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.

答:使用 visudo,将以下内容添加到您的 sudoers 文件中,将用户名替换为正确的用户名

USER        ALL = NOPASSWD: /usr/bin/systemctl restart nginx

这将允许用户使用任何或零个以下属性(即start|stop|restart(运行"/usr/bin/systemctl restart nginx"。

更多详情参考:

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

最新更新