我已在配备 AMD 处理器的 Dell Inspiron 灵越上安装了 Debian 10。我正在使用 KDE Plasma 桌面。当我尝试时
sudo dpkg -i ./palemoon_28.6.1+repack-2_amd64.deb
我明白了
[sudo] password for peter:
peter is not in the sudoers file. This incident will be reported.
我以 root 身份登录并输入
/usr/sbin/adduser peter
这返回了
adduser:用户“peter”已经存在。
然后我以 root 身份尝试了以下操作
chmod 0440 /etc/sudoers
当我尝试 sudo 时,在 Peter 帐户中,我仍然得到
peter is not in the sudoers file. This incident will be reported.
然后我以 root 身份尝试以下操作
sudo usermod -aG sudo,adm peter
当我尝试从 Peter 帐户执行 sudo 时,仍然得到相同的结果。
为 Peter 帐户打开一个新终端不会改变任何内容。
编辑
cat /etc/sudoers
root@debian:/home/peter/Downloads# 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
root@debian:/home/peter/Downloads# id peter
uid=1000(peter) gid=1000(peter) groups=1000(peter),4(adm),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),112(bluetooth),116(lpadmin),117(scanner)
答案1
作为 root,我创建了一个文件
vi /etc/sudoers.d/peter
并添加了
peter ALL=(ALL:ALL) ALL
我现在可以从 Peter 帐户执行 sudo。