错误:/etc/sudoers: syntax error near line
错误
yang@ubuntu:/etc$ sudo cat sudoers
>>> /etc/sudoers: syntax error near line 26 <<<
sudo: parse error in /etc/sudoers near line 26
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
自此,无法使用sudo命令,无法打开/etc/sudoers文件,当然也无法修改/etc/sudoers文件。
解决办法:
1、打开两个ssh终端,都是用同一个ubuntu用户登录
2、在第一个终端输入以下命令,获取pid
yang@ubuntu:~$ echo $$
3、在第二个终端,输入:
pkttyagent --process 刚刚得到的pid
4、这个时候,第二个终端会卡住,在第一个终端输入:
pkexec visudo
5、然后,第一个终端也卡主,回到第二个终端,会提示输入当前用户密码,输入
6、好吧,输入完密码,第二个终端卡主了,回到第一个终端,会发现,出现了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:/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 # See sudoers(5) for more information on "#include" directives:
#alex ALL=(ALL) NOPASSWD: ALL
#includedir /etc/sudoers.d
7、完成任务,修改完成,发现就可以继续使用sudo命令了,over
PS:这里用的编辑器是nano,以下是nano简单的保存方式:
linux下在编辑状态下退出请按Ctrl+X,会有两种情形:
①、如果文件未修改,直接退出;
②、如果修改了文件,下面会询问是否需要保存修改。输入Y确认保存,输入N不保存,按Ctrl+C取消返回。如果输入了Y,下一步会提示输入想要保存的文件名。如果不需要修改文件名直接回车就行;若想要保存成别的名字(也就是另存为)则输入新名称然后确定,这个时候也可用Ctrl+C来取消返回。
原文链接:https://blog.csdn.net/qq_43590614/article/details/125819464
错误:/etc/sudoers: syntax error near line的更多相关文章
- (转)Windows 平台下解决httpd.exe: syntax error on line 39
近来在研究PHP,结果为了Apache的安装伤神不已...小白我在安装后,启动Apache的服务虽然可以,不过,在Apache sevice monitor 中启动services时就会出现如下的问题 ...
- Ubuntu zookeeper-3.5.0-alpha启动错误 zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")(转)
昨天小猿我把Ubuntu Server64位上的 zookeeper换成了最新版本的,结果启动的时候出错:之前zookeeper-3.3.6是没有任何问题的,换成了zookeeper3.5出现了下面的 ...
- Java错误提示:Syntax error, insert "}" to complete Block
从网上复制了一段java代码到Eclipse里面,调整了一下格式,把Eclipse提示的明显有问题的地方,主要是空格,删掉了,但还是在最后一个分号那里提示“Syntax error, insert & ...
- 数据库操作语法错误(SQL syntax error)之两步走
今天在做web应用操作数据库时出现了语法错误,提示的是在“xxxxxxx”附近出现了语法错误:CODE:Error: You have an error in your SQL syntax. Che ...
- 下载个jquery-easyui-1.3.0使用,把他导入到myeclipse10里,jquery-1.7.2.min.js报错。 错误如下, Syntax error on token "Invalid Regular Expression Options", no accurate correc
1.选中报错的jquery文件“jquery-1.2.6.min.js”.2.右键选择 MyEclipse-->Exclude From Validation .3.再右键选择 MyEclips ...
- shell脚本:Syntax error: Bad for loop variable错误解决方法(转)
Linux Mint中写了一个简单的shell脚本,利用for..do..done结构计算1+2+3......+100的值,结果执行"sh -n xxx.sh"检测语法时总是报错 ...
- Linux 中出现的-bash: syntax error near unexpected token `
版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux 5中导入数据时,出现下面的错误. -bash: syntax error near unexpected token `(' 检查了 ...
- PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法
出现这个错误的原因就是语法错误,肯定是PHP程序的书写不规范造成,PHP语句标识符错了,没有在php.ini中开启短标签!八成是这个原因,啊啊啊! 今天在写PHP程序的时候总是出现这样的错误:Pars ...
- syntax error, error in :'e id=1?', expect QUES, actual QUES pos 66, line 1, column 66, token QUES错误
在查询数据库的时候报了下面的异常: syntax error, error in :'e id=1?', expect QUES, actual QUES pos 66, line 1, column ...
- php版本过低错误导致的laravel 错误:Illuminate\Foundation\helpers.php on line 233; syntax error, unexpected '?'
今天运行laravel项目发现出现错误: Parse error: syntax error, unexpected '?' ..\vendor\laravel\framework\src\Illu ...
随机推荐
- 使用阿里云产品搭建PHPWIND
2.4 安装PhpWind论坛网站 1. 本小节主要是在ECS云主机中快速安装PhpWind论坛网站的基础环境. 2. 远程登录到 PhpWind 主机服务器 ECS实例.请使用本实验 ...
- Grafana 系列文章(三):Tempo-使用 HTTP 推送 Spans
️URL: https://grafana.com/docs/tempo/latest/api_docs/pushing-spans-with-http/ Description: 有时,使用追踪系统 ...
- 构建api gateway之 动态插件
动态插件 之前已经拆解细点逐个介绍了 tcp .http 代理相关核心点,现在介绍一个让 api gateway 变得很灵活的功能实现: 动态插件. 由于 lua 的动态语言特点,我们可以比较方便做到 ...
- 时间轮TimeWheel工作原理解析
时间轮工作原理解析 一.时间轮介绍 1.时间轮的简单介绍 时间轮(TimeWheel)作为一种高效率的计时器实现方案,在1987年发表的论文Hashed and Hierarchical Timing ...
- GoLang 的协程调度和 GMP 模型
GoLang 的协程调度和 GMP 模型 GoLang 是怎么启动的 关于 GoLang 的汇编语言,请查阅 参考文献[1] 和 参考文献[2] 编写一个简单的 GoLang 程序 main.go, ...
- C端自动化实现:appium+winappdriver+python
一. 前言 有小伙伴有办公自动化的需求,特此出一篇C端自动化教程,并附带demo案例.C端的自动化比B端多一个appium,其他的操作大同小异. 二. 环境 appium:exe工具,用于启动服务,官 ...
- 题解 [SCOI2008]斜堆
好题.一道很有趣的性质提. 因为自己搞错结论然后改了 1h(悲 闲话少说,切入正题-- 这是不断插入的,所以根据套路我们会考虑最后一个插入的节点的性质.显然满足: 它是从根不停往左走的路上. 它没有右 ...
- Hbase一:Hbase介绍及特点
转载请注明出处: 1.Google的三篇论文 2003年,Google发布Google File System论文,(GFS)这是一个可扩展的分布 式文件系统,用于大型的.分布式的.对大量数据进行访问 ...
- .net core Ubuntu下docker部署(精简版)
一.首先先添加一个.netCore 项目,选择启用docker(我用的是vs2019,之前的可能需要手动点击项目添加docker支持) 没有的话需要手动添加 之后你的项目会存在这个dockerfile ...
- python爬取网页的多种方式以及保存方法
爬取网页信息并保存 bs4和lxml都是用来将接收的数据解析html 1.bs4+excel(openpyxl): import requests from bs4 import BeautifulS ...