sudo必须由uid 0拥有并设置setuid位

我正在尝试运行以下命令:

$ echo "My username is: `whoami`" My username is: d $ sudo chown -R `whoami` /usr/local/lib/node_modules sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set 

我不明白问题是什么,因为root是uid 0:

 $ id -u root 0 

而setuid似乎很好:

 $ ls -l /usr/bin/sudo -rwxr-xr-x 1 4755 root 155008 Feb 10 2014 /usr/bin/sudo 

Setuid位设置。 如果是,权限将具有s而不是第一个x

 $ ls -l /usr/bin/sudo -rwsr-xr-x 1 root root 155008 Feb 11 2014 /usr/bin/sudo 

尝试使用pkexec正确设置它:

 pkexec chmod a=rx,u+ws /usr/bin/sudo 

虽然我怀疑这是你唯一会遇到的问题。

使用root(su)登录并运行以下命令

 chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo 

在Windows上的WSL遇到了同样的问题:

退出bash。 通过高架CMD终端运行:

 lxrun /setdefaultuser root 

开始bash。 从Thirumal运行命令

 chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo 

退出Bash。 通过高架CMD终端运行:

 lxrun /setdefaultuser  

启动Bash

不能运行sudo类型

 $ sudo -l sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set 

显示错误usr / bin / sudo必须由uid 0拥有并设置setuid位

 $ ls -l /usr/bin/sudo -rwxr-xr-x 1 root root 136808 Jul 4 07:37 /usr/bin/sudo 

它的许可问题

  $ su Password:  

切换到root用户并运行该命令

 # pkexec chmod a=rx,u+ws /usr/bin/sudo 

然后通过从用户输入来检查它

 $sudo -l 

这对我来说可以

干杯….