Linux 收到消息“sudo:必须是 setuid root”,但 sudo 已经归 root 所有

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16682297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 22:58:04  来源:igfitidea点击:

Getting message "sudo: must be setuid root", but sudo IS already owned by root

linuxsudosetuid

提问by Greg Dougherty

I'm trying to run sudo, and it's failing:

我正在尝试运行 sudo,但失败了:

gregd@david $ sudo ls
sudo: must be setuid root
gregd@david $ which sudo
/usr/bin/sudo
gregd@david $ ll /usr/bin/sudo
-rwxr-xr-x 1 root root 165K 2012-05-16 00:25 /usr/bin/sudo*

Any suggestions on how to fix this?

对于如何解决这个问题,有任何的建议吗?

采纳答案by Greg Dougherty

You have to be able to log in as root, but if you can you can run this

您必须能够以 root 身份登录,但如果可以,您可以运行它

chmod u+s /usr/bin/sudo

And fix the problem

并解决问题

回答by Adam

This problem is caused sometimes when the permissions of the file, /usr/bin/sudo get set to 777. If you do something like chmod -R 777 /usr/, you can do this. It effectively ruins sudo. Here is the solution if this is your problem, and the accepted answer doesn't work:

这个问题有时是因为文件的权限,/usr/bin/sudo 设置为777。如果你做类似的事情chmod -R 777 /usr/,你可以这样做。它有效地破坏了 sudo。如果这是您的问题,这是解决方案,并且接受的答案不起作用:

To fix:

修理:

Restart pc, press shift at boot menu.

重启电脑,在启动菜单按shift。

This should bring up GNU GRUB (ie recovery mode) menu.

这应该会调出 GNU GRUB(即恢复模式)菜单。

  • If this doesn't work, just restart mid boot and choose recovery mode when prompted on next launch.
  • 如果这不起作用,只需在启动中重新启动并在下次启动时出现提示时选择恢复模式。

Select the line which starts with Advanced options

选择以高级选项开头的行

Select the topmost version of the OS ending with ("recovery mode")

选择以(“恢复模式”)结尾的操作系统的最高版本

Press enter

按回车

In the following menu, go down to "Drop to root shell prompt"

在以下菜单中,转到“Drop to root shell prompt”

Type the following:

键入以下内容:

mount -o remount,rw /

mount --all

chown root:root /usr/bin/sudo

chmod 4755 /usr/bin/sudo

restart

This should restore sudo privellages.

这应该恢复 sudo privellages。