linux 下普通用户无法使用sudo命令的解决方法

时间:2022-05-20 07:51:59

装完linux系统,发现普通用户无法使用sudo 命令,linux 下普通用户无法使用sudo命令的解决方法

提示:xinhuan(普通用户)is not in the sudoers file, This incident will be reported.

大概意思是说xinhuan 这个用户不在sudoers这个文件里,这个事件将要被报告的。

我们可以这样做

[xinhuan@localhost~]$su - (切换到root)

输入超级用户root密码

[xinhuan@localhost~]#chmod u+w /etc/sudoers (添加root对sudoers这个文件的写权限)

[xinhuan@localhost~]#vi /etc/sudoers (编辑sudoers,把xinhuan这个用户添加进去)

找到 root ALL=(ALL) ALL 这行 ,并在此行下添加

xinhuan ALL=(ALL) ALL

:wq (保存并退出)

[xinhuan@localhost~]#chmod u-w /etc/sudoers (这里我们再把root对sudoers这个文件的写权限去掉,嘿嘿linux 下普通用户无法使用sudo命令的解决方法)