Невозможно изменить владельца обратно на корень (нельзя использовать команду sudo) в WSL Ubuntu

Я столкнулся с этой проблемой, когда хочу использовать команду sudo :

sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

, затем попытался найти решение по аналогичному вопросу, чтобы сменить владельца. обратно в корень:

$ pkexec visudo

также я пробовал этот

$ pkexec chown root:root /etc/sudoers /etc/sudoers.d -R

, но я столкнулся с другой проблемой с этими командами:

Error getting authority: Error initializing authority: Could not connect: No such file or directory

Так есть ли решение этой проблемы?


Фрагменты полной версии оболочки:

ubuntu@LAPTOP-D4T16P7J:~$ sudo -i
sudo: /etc/sudoers is owned by uid 1000, should be 0
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
ubuntu@LAPTOP-D4T16P7J:~$ pkexec visudo
Error getting authority: Error initializing authority: Could not connect: No such file or directory
ubuntu@LAPTOP-D4T16P7J:~$ pkexec chown root:root /etc/sudoers /etc/sudoers.d -R
Error getting authority: Error initializing authority: Could not connect: No such file or directory


Это мой файл / etc / sudoers:

ubuntu@LAPTOP-D4T16P7J:~$ cat /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:/snap/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


Информация об ОС:

  • Ubuntu WSL2.
1
задан 6 May 2020 в 23:28

1 ответ

Ответ был следующим:

  • получить доступ к пользователю root, введя эту команду в командной строке Windows (CMD):

     wsl -u root
    
  • сменить владельца файла / etc / sudoers на root:

     chown root: root / etc / sudoers
    


Спасибо @Terrance за помощь.

1
ответ дан 19 June 2020 в 21:42

Другие вопросы по тегам:

Похожие вопросы: