我的服务器崩溃了,我不得不通过电源按钮重新启动它。但是,一旦我重新启动它,我就无法再运行 sudo。当我尝试时,我得到了
>>> /etc/sudoers: syntax error near line 1 <<<
sudo: parse error in /etc/sudoers near line 1
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
然后我跑了
pkexec visudo
返回
��������������������������ï¿ï¿½u�fZc�f�<��^F� ��^H���g���&^R& k^N�^[N)��@{^H�Ƽ^P��8^^����0,(iȼ4_ï¿ï¿½ï¿½d$9��y^YW�ż^O}�f��ȼ0v��lE"G^A^@^Y1���$
那么我该如何重新创建我的 sudoers 文件,或者我是否已经失败了?
答案1
/etc/sudoers
这是Trusty 中的默认文件:
#
# 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"
# 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:
#includedir /etc/sudoers.d
您可以/etc/sudoers
使用 Live DVD 将损坏的文件替换为该文件:
- 从 Live DVD 启动
- Ctrl使用+ Alt+打开终端T
- 运行
lsblk
以查看root
驱动器上的分区映射到哪个块设备 root
在驱动器上安装分区:(sudo mount /dev/<partition_block_device> /mnt
其中<partition_block_device>
=root
分区的块设备)- 跑步
sudo gedit /mnt/etc/sudoers
/etc/sudoers
粘贴干净文件的内容- 节省
- 辞职
- 跑步
exit
- 重启