[Others] 求助!突然没有权限使用sudo
Tofloor
poster avatar
umasou
deepin
2021-09-27 07:26
Author

系统中只有一个普通用户,平常都是用sudo来进行需要root权限的操作,今天使用sudo突然没权限了,提示不在 sudoers 文件中:

因为没有使用过root用户,所以直接su到root时密码也忘记了。

然后我尝试了在开机过程中修改grub引导,使用root登录到bash的操作,然而也不行,提示the root account is locked:

现在我该怎么办?为何会突然失去sudo的权限,这期间我只进行过系统更新,没有编辑过sudoers及修改用户组等操作。

当前系统信息:

Reply Favorite View the author
All Replies
wtz
deepin
2021-09-27 16:59
#1

用U盘做一个Live系统修复吧:http://cdimage.deepin.com/live-system/deepin-live-system-2.0-amd64.iso

Reply View the author
zccrs
deepin
2021-09-27 17:50
#2

还记得是从哪个版本升级到哪个版的吗?

Reply View the author
qq8645
deepin
2021-09-27 18:28
#3

这个问题在新版的debian中出现过。通常的解决办法是:

1. 用编辑器打开 /etc/sudoers,如果切换不了root,就用ventoy制作启动U盘,启动live系统再打开;

2. 添加以下红色背景内容,保存后退出

# User privilege specification

root ALL=(ALL:ALL) ALL

umasou  ALL=(ALL:ALL) ALL

Reply View the author
umasou
deepin
2021-09-27 18:36
#4
qq8645

这个问题在新版的debian中出现过。通常的解决办法是:

1. 用编辑器打开 /etc/sudoers,如果切换不了root,就用ventoy制作启动U盘,启动live系统再打开;

2. 添加以下红色背景内容,保存后退出

# User privilege specification

root ALL=(ALL:ALL) ALL

umasou  ALL=(ALL:ALL) ALL

谢谢,已经解决了,刚开始还用win pe,进去发现编辑不了ext4文件系统的文件,换了deepin live进去编辑sudoers文件就ok了。

Reply View the author
umasou
deepin
2021-09-27 18:43
#5

另外,deepin的live系统进入装不了vi、vim等工具,编辑/etc/sudoers文件可以使用sed进行。

先cat /etc/sudoers文件看一下原始内容,然后执行以下命令写入授权:

sed -i '21 i\umasou  ALL=(ALL:ALL) ALL' sudoers

其中,21代表写入的行,umasou是自己的用户名。

写完之后重启进入系统,可以把当前用户加回到sudo组:

sudo usermod -a -G sudo umasou

给以后遇到这个问题的同学留个线索。

Reply View the author
Comments
qq8645
2021-09-27 22:49
nano 应该可以用的
zhang_22521
deepin
2021-09-27 20:33
#6

pkexec chmod 0440 /etc/sudoers 恢复原来的权限就可以了

Reply View the author