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

相关文章

Linux中的ARP防火墙主要用于防御ARP欺骗攻击,其效果取决于多...
insmod和modprobe加-f参数导致Invalid module format错误 这...
将ArchLinux安装到U盘 几个月前入门Arch的时候上网搜了不少安...
1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...