Ubuntu修复sudoer配置文件
0x00 问题
在修改sudoer 的时候出现语法错误,无法解析,导致sudo不工作出现以下提示:
( pkexec : 以超级身份运行)
0x01 解决问题
首先可以尝试进入root用户修改sudoer配置文件;但是在安装Ubuntu时可能没有设置root账号密码,这时无法切换到root用户,提示一下错误;
$ su - root
Password:
su: Authentication failure
以超级身份运行 visudo:
$:pkexec visudo
这时会弹出对话框,要求输入密码:
这时输入之前的sudo 密码即可打开visudo编辑sudoer配置文件;
0x02 sudoer 配置文件
#
# 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:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
#%sudo ALL=(ALL:ALL) ALL
%sudo ALL=NOPASSWD:ALL #配置 sudo 不需要密码
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d