无法在 Debian 10 中执行 sudo

6 debian sudo

我在 VirtualBox VM 中安装了Debian Buster/10 x86_64 用于测试 GCC 7。桌面是 LXDE(在现实生活中不要选择这个,除非你对 SSH 访问没有问题;LXDE 在现实生活中在 Buster 上不起作用)。我认为操作系统确实是启用了测试的 Debian 9。

我将自己加入sudoadm群组。没有sudoers,adminwheel组:

# id jwalton
uid=1000(jwalton) gid=1000(jwalton) groups=1000(jwalton),4(adm),24(cdrom),25(floppy),27(sudo),
29(audio),30(dip),44(video),46(plugdev),108(netdev),113(bluetooth),114(lpadmin),118(scanner)
Run Code Online (Sandbox Code Playgroud)

我还取消sudo了 sudoers 文件中组行的注释:

# cat /etc/sudoers
#
# 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
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
sudo    ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
Run Code Online (Sandbox Code Playgroud)

我重新启动了机器。当我尝试sudo

$ sudo apt-get install emacs-nox
jwalton is not in the sudoers file.  This incident will be reported.
Run Code Online (Sandbox Code Playgroud)

我浏览了手册页,但没有任何东西因为弯曲而跳出来。但它的手册页很大,我可能错过了一些明显的内容。

为什么我不能sudo?我的配置有什么问题?

Dea*_*rip 17

您是否取消注释该行或删除前导%?分组以/etc/sudoers百分号开头。你的线路应该是:

%sudo   ALL=(ALL:ALL) ALL
Run Code Online (Sandbox Code Playgroud)

这允许任何属于该sudo组成员的人都可以使用 sudo。

  • 奇怪的是,将 jwalton 注销并重新登录应该有效。也许`/var/log/auth.log` 中的某些内容会有所帮助。 (3认同)