计算机知识分享网

【debian】debian12用户名不在 sudoers文件中的解决

终端输入su回车,输入 root 密码,回车,切换到 root 用户

打开 sudoers 文件:vi /etc/sudoers
找到 # Allow members of group sudo to execute any command
在 %sudo ALL=(ALL:ALL) ALL 下面添加 
yonghumigndavid ALL=(ALL:ALL) ALL
yonghumigndavid 为前面无法执行 sudo 命令的用户名
最后执行权限
pkexec chmod 440 /etc/sudoers
pkexec chmod 440 /etc/sudoers.d/README
pkexec chmod 440 /etc/sudoers.d
看到下面可以正常使用sudo
oot@debian:/home/debian# pkexec chmod 440 /etc/sudoers
root@debian:/home/debian# pkexec chmod 440 /etc/sudoers.d/README
root@debian:/home/debian# pkexec chmod 440 /etc/sudoers.d
root@debian:/home/debian# exit
exit
debian@debian:~$ sudo
usage: sudo -h | -K | -k | -V
usage: sudo -v [-ABkNnS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-ABkNnS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command [arg ...]]
usage: sudo [-ABbEHkNnPS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T
            timeout] [-u user] [VAR=value] [-i | -s] [command [arg ...]]
usage: sudo -e [-ABkNnS] [-r role] [-t type] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-T
            timeout] [-u user] file ...

#Debian