Я получаю следующую ошибку при попытке обновить свои репозитории,
avinash@avinash-VirtualBox:~$ sudo apt-get update
sudo: unable to stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
Кажется, что я случайно удалил свой файл /etc/sudoers. Файл /etc/sudoers действительно принадлежал к sudo пакету , поэтому я пытаюсь переустановить sudo на pkexec, но это не сработает.
avinash@avinash-VirtualBox:~$ pkexec apt-get install sudo
Reading package lists... Done
Building dependency tree
Reading state information... Done
sudo is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 301 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up sudo (1.8.6p3-0ubuntu3.1) ...
WARNING: /etc/sudoers not present!
chown: cannot access ‘/etc/sudoers’: No such file or directory
dpkg: error processing sudo (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
sudo
E: Sub-process /usr/bin/dpkg returned an error code (1)
avinash@avinash-VirtualBox:~$
А также я попытался,
avinash@avinash-VirtualBox:~$ pkexec 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 301 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for sudo:amd64
Как я могу сделать sudo команда снова работать?
После того, как я сделал резервную копию файла /etc/sudoers:
sudo mv /etc/sudoers{,.bak}
Я получаю те же ошибки, что и в вашем случае.
Если вы используете
не будет работать, потому что apt-get увидит, что:
sudo is already the newest version.
Если вы используете:
pkexec apt-get install --reinstall sudo
также не будет работать, потому что файл /etc/sudoers
Но если вы используете:
pkexec apt-get purge sudo
pkexec apt-get install sudo
, как описано в этом ответе, все будет работать как шарм. Я могу сказать это, потому что я просто проверяю его снова.
Итак, нет смысла терять время и загружать вашу систему с живого диска.
Вот исходное содержимое /etc/sudoers в Ubuntu 13.10:
#
# 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
И разрешения:
-r--r----- 1 root root
Чтобы применить их, это chmod 440 /etc/sudoers и chown root:root /etc/sudoers
выполнить pkexec nano /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
# 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