0

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set I have this since I tried to give a chroot user sudo permissions.

The commande I ran :

chown root:root /usr/bin/sudo

chmod 4755 /usr/bin/sudo

and after this I got the error.

I wanted to execute it on my chroot environement but I wrote it too fast I didn't realize

I tried to resolve the issue with pkexec but it can't connect with my password.

in /bin : -rwxr-xr-x 1 root root 166056 Jan 19 14:21 sudo

in /usr/bin : -rwxr-xr-x 1 root root 166056 Jan 19 14:21 sudo

I really don't understand what's happening

1
  • 2
    You gave away ownership to a critical directory time to re install.
    – David
    Mar 26, 2021 at 14:17

2 Answers 2

1

You somehow removed the setuid bit from sudo. The permissions for the file are -rwxr-xr-x while they should be -rwsr-xr-x.

I'm not quite sure how you did this, because when I tried to run the two commands you ran (of course not on /usr/bin/sudo but on a copy for safety reasons) they did not remove the setuid bit (assuming you were running them as root, because if you weren't running them as root they should simply fail and do nothing). Maybe you typed chmod 0755 instead of chmod 4755 ?

Anyway, I understand you lost access to sudo now and can't perform anything as root. You have to boot from live system on Ubuntu installation medium, mount your main system partition and execute the following:

sudo chmod u+s /mountpoint/of/your/partition/usr/bin/sudo

where /mountpoint/of/your/partition of course needs to be substituted by the actual mountpoint where you mounted your partition.

1

Read man 2 chown. Your sudo chown ... cleared the S_ISUID and S_ISGID mode bits, even though you're root. This has been the behavior since Linux 2.2.13.

When you tried sudo chmod ..., sudo wasn't SETUID.

To repair this mistake, either switch to the root shell you have running in another window (What, you omitted this preliminary preparation? It's mandatory, when messing with authentication/authorization tools), or boot from a Live CD/USB and fix it from there.

You must log in to answer this question.

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