• 推荐使用最新版火狐浏览器或Chrome浏览器访问本网站
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Ubuntu修复sudoer配置文件

服务器 紫鹰 3年前 (2020-10-21) 1638次浏览 0个评论 扫描二维码

Ubuntu修复sudoer配置文件

0x00 问题

在修改sudoer 的时候出现语法错误,无法解析,导致sudo不工作出现以下提示:

Ubuntu 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

版权所有丨如未注明 , 均为原创丨
转载请注明原文链接:Ubuntu修复sudoer配置文件
喜欢 (12)
[谢谢打赏!]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址