我意外地/etc/
在自己拥有的 aws ec2 中拥有了 Ubuntu 用户/etc/
,现在每当我使用时都会出现此消息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
我昨天到现在一直在这里寻找答案,但我还没有找到任何不需要停止实例的解决方案。
(这与发布的“另一个问题”不同,为什么?因为根据我读过的评论,他仍然可以根据“sudo”运行“,而且这是一个云服务器)
这是我的/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
我该如何解决?
答案1
你需要启动 Live CD 并运行
sudo chown root:root -R /media/$USER/*/etc
您需要在文件浏览器中打开文件夹来安装磁盘
答案2
运行:vim /etc/sudoers
您将发现类似如下的一行:
$ROOT: $ALL
在后面插入此行:
$ <your_uid> : $ALL
但您需要 root 权限才能执行此操作。
答案3
#
# 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 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
**ee209195 ALL=(ALL:ALL) ALL # TODO ADD THIS LINE With your uid**
# 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