Ubuntu 中出现username is not in the sudoers file. This incident will be reported的错误

参考网址http://www.maketecheasier.com/fixing-sudo-error-in-ubuntu/

使用环境Ubuntu Linux系统下:

在学习鸟哥的私房菜时,使用了如下命令

<span style="font-size:18px;">usermod -G users username</span>

username为你自己的用户名。

由于没有使用-a参数导致我的用户被分到了users用户组里,而原先的用户组被重置掉,仅剩下users用户组

由于没有sudo用户组,因此无法使用sudo的命令。

解决方法:在x-windows图形界面下reboot系统

然后进入grub界面选择选中的项

选择fsck,等待30秒左右

点击root项进入root下的命令行

在命令行中输入

<span style="font-size:18px;">usermod -a -G sudo username
usermod -a -G adm username</span>

有的系统是admin,但我的系统是adm,不过我看了sudoers文件里的内容中用的是admin,

在我的/etc/group中没有admin这一项,所以我添加adm是无法让我的用户使用sudo的,因此还是要加入sudo用户组

<span style="font-size:18px;">#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
 
# Host alias specification
 
# User alias specification
 
# Cmnd alias specification
 
# User privilege specification
root    ALL=(ALL:ALL) ALL
 
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
 
# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
 
#includedir /etc/sudoers.d</span>

然后点击resume重启系统

重启后就可以进入root了。

如果你可以直接用su - 命令直接进入超级root用户,那么就可以直接修改/etc/sudoers文件

并改动username用户所属的用户组。




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值