我不明白这一点? sudo 的其他用法没问题。
[oracle@o plugins]$ su
Password:
[root@ plugins]# su nrpe
bash-3.2$ /home/oracle/obiee/instances/instance1/bifoundation/OracleBIApplication/coreapplication/setup/bi-init.sh
bash: /home/oracle/obiee/instances/instance1/bifoundation/OracleBIApplication/coreapplication/setup/bi-init.sh: Permission denied
bash-3.2$ sudo -l
Matching Defaults entries for nrpe on this host:
env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE LC_COLLATE
LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET
XAUTHORITY"
Runas and Command-specific defaults for nrpe:
User nrpe may run the following commands on this host:
(ALL) NOPASSWD:
/home/oracle/obiee/instances/instance1/bifoundation/OracleBIApplication/coreapplication/setup/bi-init.sh
bash-3.2$
答案1
chmod +x /home/oracle/obiee/instances/instance1/bifoundation/OracleBIApplication/coreapplication/setup/bi-init.sh
您需要先将脚本设置为“可执行”,然后才能实际执行它。这是为了阻止人们执行随机文本文件并可能对其系统进行哈希处理。
另一个问题是脚本的权限。您需要确保脚本所在的目录可供世界/您希望能够访问的用户读取。