当前位置: 移动技术网 > 科技>操作系统>Linux > sudo service: command not found 报错的解决方法

sudo service: command not found 报错的解决方法

2018年11月08日  | 移动技术网科技  | 我要评论
问题:
配置成功sudo后,执行sudo /etc/init.d/httpd restart 正常。
但执行sudo  service httpd restart出现一下错误:
sudo: service: command not found
 
解决方法:
1.将service的路径写入path.
$vi .bash_profile

复制代码
代码如下:

export path=$path:/sbin
$source source

注意:不建议这样设置,这样加大了安全隐患。
 
2.修改 sudo 配置文件 /etc/sudoers

复制代码
代码如下:

# visudo
defaults 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 path"

;在env_keep中加入path.
#vi /etc/profile

复制代码
代码如下:

# path manipulation
#if [ "$euid" = "0" ]; then ;
修改为
gid=`/usr/bin/id -g`
if [ $gid -eq 10 ];then

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网