错误:/etc/sudoers: syntax error near line
2024-10-16 02:30:56
错误
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
最新文章
- Scala快速概览
- HTTP及网络安全
- step2-------使用myeclipse创建maven java web项目
- 【转】web集群时session同步的3种方法
- java和linux的编码
- MATLAB学习笔记(五)&mdash;&mdash;MATLAB绘图
- php://input,$_POST,$HTTP_RAW_POST_DATA区别
- Codeforces Round #261 (Div. 2) B
- Bash String Manipulation Examples – Length, Substring, Find and Replace--reference
- SharePoint 页面Pages和SitePages目录创建不成功解决
- JavaScript引用类型之Array数组之强大的splice()方法
- 原生js判断css动画结束 css 动画结束的回调函数
- 基于Verilog HDL 的数字电压表设计
- Redis数据类型之Set
- mysql读写分离的操作动作依据(读写分离基本依据)
- Xcode 单元测试
- 用django2.1开发公司官网(上)
- 【Android】Android模拟器快速root
- JMeter做http接口功能测试
- shell脚本返回字符串
热门文章
- Ant Design Table 如何动态自定义?Ant Popover 遮挡?
- ChatGPT 背后的“功臣”——RLHF 技术详解
- MySQL 字符串长度 char_length、length
- while循環的一些判斷條件和讀取循環精簡方法
- 如何将WebAssembly优化到2MB?
- Node.js学习笔记-----day05 (使用MongonDB重写学生信息管理案例)
- CSS 3 所有的选择器整理(2023.2)
- App测试Android的闪退总结
- 2023.1.13 [网络流24题] 餐巾计划问题 LuoguP1251
- Vue27 scoped样式