错误

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的更多相关文章

  1. (转)Windows 平台下解决httpd.exe: syntax error on line 39

    近来在研究PHP,结果为了Apache的安装伤神不已...小白我在安装后,启动Apache的服务虽然可以,不过,在Apache sevice monitor 中启动services时就会出现如下的问题 ...

  2. Ubuntu zookeeper-3.5.0-alpha启动错误 zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")(转)

    昨天小猿我把Ubuntu Server64位上的 zookeeper换成了最新版本的,结果启动的时候出错:之前zookeeper-3.3.6是没有任何问题的,换成了zookeeper3.5出现了下面的 ...

  3. Java错误提示:Syntax error, insert "}" to complete Block

    从网上复制了一段java代码到Eclipse里面,调整了一下格式,把Eclipse提示的明显有问题的地方,主要是空格,删掉了,但还是在最后一个分号那里提示“Syntax error, insert & ...

  4. 数据库操作语法错误(SQL syntax error)之两步走

    今天在做web应用操作数据库时出现了语法错误,提示的是在“xxxxxxx”附近出现了语法错误:CODE:Error: You have an error in your SQL syntax. Che ...

  5. 下载个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 ...

  6. shell脚本:Syntax error: Bad for loop variable错误解决方法(转)

    Linux Mint中写了一个简单的shell脚本,利用for..do..done结构计算1+2+3......+100的值,结果执行"sh -n xxx.sh"检测语法时总是报错 ...

  7. Linux 中出现的-bash: syntax error near unexpected token `

    版权声明:本文为博主原创文章,未经博主允许不得转载. 在Linux 5中导入数据时,出现下面的错误. -bash: syntax error near unexpected token `(' 检查了 ...

  8. PHP错误Parse error: syntax error, unexpected end of file in test.php on line 12解决方法

    出现这个错误的原因就是语法错误,肯定是PHP程序的书写不规范造成,PHP语句标识符错了,没有在php.ini中开启短标签!八成是这个原因,啊啊啊! 今天在写PHP程序的时候总是出现这样的错误:Pars ...

  9. 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 ...

  10. php版本过低错误导致的laravel 错误:Illuminate\Foundation\helpers.php on line 233; syntax error, unexpected '?'

    今天运行laravel项目发现出现错误: Parse error: syntax error, unexpected '?'  ..\vendor\laravel\framework\src\Illu ...

随机推荐

  1. Ubuntu 安装 samba 服务器

    下载 samba 工具 sudo apt install samba samba-common 配置 sudo vim /etc/samba/smb.conf // 复制到san.conf最下面 [u ...

  2. vue3+quasar+capacitor开发多平台项目,使用cordova和capacitor插件(支持所有前端框架)

    先看文档 框架文档地址:https://quasar.dev/start/quasar-cli 创建项目 npm init quasar 运行与打包命令 npx quasar dev npx quas ...

  3. ajax 用 get方法 验证登录

    get-login-ajax.html --------------------------------------------- <body> <input type=" ...

  4. Win10下yolov8 tensorrt模型加速部署【实战】

    Win10下yolov8 tensorrt模型加速部署[实战] TensorRT-Alpha基于tensorrt+cuda c++实现模型end2end的gpu加速,支持win10.linux,在20 ...

  5. 结对项目总结 -- 基于Qt开发的win10桌面应用

    担任角色 在这次结对项目中,由于采用了我的个人项目作为参考,所以我继续担任后端开发的角色. 开发环境 前端采用Qt Creator4.13.2 (Community) 后端采用C++ 如何复用个人项目 ...

  6. 文盘Rust -- rust 连接云上数仓 starwift

    作者:京东云 贾世闻 最近想看看 rust 如何集成 clickhouse,又犯了好吃懒做的心理(不想自己建环境),刚好京东云发布了兼容ck 的云原生数仓 Starwfit,于是搞了个实例折腾一番. ...

  7. 一文看懂 Python 中的函数参数

    函数定义中的参数也就是形式参数,规定了在调用函数时如何传递实际参数以及这些参数有无默认值. 实参传递方式 def f(a): print(a) 实参传递方式有两种,位置和关键字.对于上面定义的函数 f ...

  8. MySQL数据库报1055错误

    有点坑啊,当初装MySQL数据库的时候没有整配置文件,结果MySQL报1055错误的时候,网上的解决办法都说如果需要永久生效的话,只能通过改配置文件实现,but,我没有配置文件,蜜汁尴尬啊 1.已安装 ...

  9. UBUNTU18.04安装使用ORB-SLAM2

    1.下载: git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2 2.依赖项: sudo apt install autotools ...

  10. ROS入门:服务

    服务端实现一个加法,将结果反馈给客户端 客户端将要计算的和的两个数发给服务的. 1.自定义服务数据 创建一个srv文件:AddTwoInts.srv int64 a int64 b --- int64 ...