系统环境:ubuntu 12.04linux
情况:ubuntu
由于修改了/etc/sudoers以及相关权限,致使sudo没法使用,刚好Ubuntu的root密码没有设置。ide
错误以下:this
~$ sudo sudo: >>> /etc/sudoers:syntax error 在行 21 附近<<< sudo: /etc/sudoers 中第 21 行附近有解析错误 sudo: 没有找到有效的 sudoers 资源,退出 sudo: 没法初始化策略插件
因而,只能进去单用户模式(拥有root权力)去修改,在Ubuntu下,开机时长按shift出现各类模式,选择第二个recovery mode,按e进去编辑。spa
解决方法:插件
一、重启ubuntu,启动时按Esc或Shift键,能够看到引导选项;code
二、在引导选项中选择Recovery模式的那一项来引导;blog
三、进入Recovery Menu页面,选择root,也就是进入试用root用户进行系统恢复,在这里能够执行超级用户的权限的操做,回车后能够看到熟悉的 root@user ~# 命令提示符;ci
四、设置或者撤销/etc/sudoers文件的权限,也能够将该文件改回到发生错误以前的状态。资源
chmod 666 /dev/null mount -o remount rw / vi /etc/sudoers 恢复本文件内容并存盘
五、退出Recovery模式,从新启动ubuntu。
PS:固然也能够用ubuntu光盘引导系统,而后mount相应的磁盘,而后修改/etc/sudoers文件,进入系统,就能够正常启动了(linux使用熟练的话不妨一试)。
# /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # # See the man page for details on how to write a sudoers file. # Defaults env_reset # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL) ALL # Allow members of group sudo to execute any command after they have # provided their password # (Note that later entries override this, so you might need to move # it further down) %sudo ALL=(ALL) ALL # #includedir /etc/sudoers.d # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL