如何编辑无效的 sudoers 文件?它会引发以下错误,并且不允许我再次编辑以修复它。
这是发生的事情:
$ sudo visudo
>>> /etc/sudoers: syntax error near line 28 <<<
sudo: parse error in /etc/sudoers near line 28
sudo: no valid sudoers sources found, quitting
Run Code Online (Sandbox Code Playgroud) 在/etc/sudoers
我看到这个:
# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
Run Code Online (Sandbox Code Playgroud)
那么如何将用户添加到该sudo
组?
我今天全新安装了 Ubuntu 11.10,然后安装了 VirtualBox。这需要我将自己添加到 vboxusers 组,并且由于 11.10 似乎不再有图形应用程序来将用户添加到组中,因此我运行了以下命令:
sudo usermod -G vboxusers stephane
Run Code Online (Sandbox Code Playgroud)
这是个问题。我现在看到我应该运行的是:
sudo usermod -aG vboxusers stephane
Run Code Online (Sandbox Code Playgroud)
最终结果是我不再属于我应该加入的组。包括运行“sudo”所需的任何组。当我现在以 sudo 身份运行任何命令时,我得到以下信息:
$ sudo ls
[sudo] password for stephane:
stephane is not in the sudoers file. This incident will be reported.
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题,还是我需要从头开始重新安装?