Red Hat普通用户不能执行sudo问题解决

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

首先查找一下sudoers文件存放在哪里:

$ whereis sudoers
sudoers: /etc/sudoers.d /etc/sudoers /usr/share/man/man5/sudoers.5.gz

对sudoers的修改需要root权限,所以要登录root用户:

su - root

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

chmod u+w /etc/sudoers

修改sudoers文件,找到root    ALL=(ALL)       ALL,在此行下面增加一行:

yourname    ALL=(ALL)       ALL 

将sudeors文件的权限修改回来:

chmod u-w /etc/sudoers

退出shell并重新登录即可。 

猜你喜欢

转载自eric-gao.iteye.com/blog/2103471
RED