linux – 创建组以在CentOS中重新启动服务

前端之家收集整理的这篇文章主要介绍了linux – 创建组以在CentOS中重新启动服务前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
SYSTEM:CentOS 6.2版(最终版)

我试图只允许某个组的用户让它调用websupport访问重启2服务:mysqld和httpd

编辑:我不想给这些用户sudo访问权限

我已将这些行添加到/ etc / sudoers:

%websupport ALL = NOPASSWD:/etc/init.d/httpd

%websupport ALL = NOPASSWD:/etc/init.d/MysqLd

用户身份登录并尝试运行时:

/etc/init.d/httpd restart

我得到这个结果:

rm: cannot remove ‘/var/run/httpd/httpd.pid’: Permission Denied [Failed]
rm: cannot remove ‘/var/lock/subsys/httpd’ : Permission Denied
rm: cannot remove ‘/var/run/httpd/httpd.pid’ : Permission Denied
Starting httpd: httpd: apr_sockaddr_info_get() Failed for wssapache
httpd: Could not reliably determine the server’s fully qualified domain name,using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available,shutting down
Unable to open logs [Failed]

试图运行时:

/etc/init.d/MysqLd restart

我得到这个结果:

cat: /var/run/MysqLd/MysqLd.pid: Permission denied
Stopping MysqLd: [Failed]
Starting MysqLd: [ OK ]

解决方法

您的sudoers中的条目看起来不错.您需要使用sudo来运行命令,例如
sudo etc/init.d/httpd restart

sudo etc/init.d/MysqLd restart

您也可以组合sudoers中的条目

%websupport ALL=NOPASSWD:/etc/init.d/MysqLd,/etc/init.d/httpd
原文链接:https://www.f2er.com/linux/397106.html

猜你在找的Linux相关文章