如何以 root 身份修复空的 /etc/sudoers?

如何以 root 身份修复空的 /etc/sudoers?

我做到了

root@masi:~# visudo -x /etc/sudoers
root@masi:~# exit
logout
masi@masi:~$ sudo apt-get install vim
>>> /etc/sudoers: syntax error near line 1 <<<

我得到这个是因为该文件现在是空的,仅包含{\n}.如果有人可以向我发送/etc/sudoersDebian 8.5 的默认文件,那就太好了。

我愿意

root@masi:/home/masi# apt-get install --reinstall sudo
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/855 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 136923 files and directories currently installed.)
Preparing to unpack .../sudo_1.8.10p3-1+deb8u3_amd64.deb ...
Unpacking sudo (1.8.10p3-1+deb8u3) over (1.8.10p3-1+deb8u3) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (215-17+deb8u4) ...
Setting up sudo (1.8.10p3-1+deb8u3) ...

root@masi:/home/masi# exit

masi@masi:~$ sudo apt-get install vim
>>> /etc/sudoers: syntax error near line 1 <<<
...

答案1

解决方案为 root by adonis' /etc/sudoers,我做了gedit /etc/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"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(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

完毕!

相关内容