3

I am trying to run the following command:

$ 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

I don't understand what the problem is because root is uid 0:

$ id -u root
0

And the setuid seem fine:

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

5 Answers 5

17

The Setuid bit is not set. If it were, the permissions would have an s instead of the first x:

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

Try using pkexec to set it correctly:

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

Though I doubt that's the only problem you are going to have.

5
  • Cool, I didn't know that one - could have saved me grief the other day! Feb 11, 2015 at 14:43
  • 1
    Oh! Look! I can upvote twice!
    – Fabby
    Feb 11, 2015 at 14:49
  • i got this "pkexec must be setuid root" what should i do? Oct 27, 2021 at 6:55
  • @user12158726 then you're much worse off and will need to reboot and use recovery shell, or use a live USB, to fix permissions.
    – muru
    Oct 27, 2021 at 7:41
  • pkexec must be setuid root
    – keramat
    Jan 14 at 17:46
2

Login with root (su) and run the following command

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

Cant run sudo type

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

shows error usr/bin/sudo must be owned by uid 0 and have the setuid bit set

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

Its beacuase of Permission issue

 $ su
 Password: <type your root password>

Switch to root user and run the command

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

Then check it by typing from the user

$sudo -l

it Works fine for me

Cheers....

0

I had the same problem with my WSL on Windows:

Exit bash. Run via elevated CMD Terminal:

lxrun /setdefaultuser root

Start bash. Run the command from Thirumal

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

Exit Bash. Run via elevated CMD Terminal:

lxrun /setdefaultuser <Your Original User>

Start Bash

0

1 - on an elevated CMD change default user to root:

ubuntu1804.exe config --default-user root

2 - open bash (zsh in my case) and change ownership:

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

3 - on an elevated CMD change default user back to my username

ubuntu1804.exe config --default-user [my_username]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .