sudoers 文件损坏

sudoers 文件损坏

我的服务器崩溃了,我不得不通过电源按钮重新启动它。但是,一旦我重新启动它,我就无法再运行 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 将损坏的文件替换为该文件:

  1. 从 Live DVD 启动
  2. Ctrl使用+ Alt+打开终端T
  3. 运行lsblk以查看root驱动器上的分区映射到哪个块设备
  4. root在驱动器上安装分区:(sudo mount /dev/<partition_block_device> /mnt其中<partition_block_device>=root分区的块设备)
  5. 跑步sudo gedit /mnt/etc/sudoers
  6. /etc/sudoers粘贴干净文件的内容
  7. 节省
  8. 辞职
  9. 跑步exit
  10. 重启

相关内容