Linux Redhat 一般用户不能执行sudo问题的解决办法

   在Redhat下,一般用户执行sudo命令时,系统会报出"is not in the sudoers file. This incident will be reported"这样的错误。原因是Redhat在建立用户时并没有把用户自动加入到sudo用户列表中。

    先从管理员那里要到root权限,然后查找一下sudoers 文件存放在哪里。敲击命令:

 

whereis sudoers
    系统一般会返回如下内容:

 

sudoers: /etc/sudoers /usr/share/man/man5/sudoers.5.gz
     对sudoers的修改需要root权限,所以要登录root用户:

 

su - root
   sudoers文件默认是只读的,所以要先修改一下它的权限:

 

chmod u+w /etc/sudoers

    使用vi修改sudoers文件

 

vi /etc/sudoers
     找到如下这行:

 

 

root    ALL=(ALL)       ALL
     如果你的用户名是yourname,那么在上面这行的下面增加如下内容:

 

 

yourname    ALL=(ALL)       ALL
     从vi中保存退出,再将sudeors文件的权限修改回来:

 

 

chmod u-w /etc/sudoers
     最后就是退出shell,再重新登录。

 

猜你喜欢

转载自nswish.iteye.com/blog/1441655
今日推荐