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

In Linux, sudo is the utility that provides the root permissions. The password will be required for the execution of the command running with sudo. Users may encounter the “sudo: /usr/bin/sudo must be owned by uid 0” error while executing different commands for sudo.

This post will demonstrate the reasons and solutions for the given error. The content for the post is as follows:

Reason: Wrong Permission is Set to the /usr/bin/sudo File

The cause for this error is that the permission “777” is set on the “/usr/bin/sudo” file. Another scenario in which you may encounter this error is two or more administration permissions are added to the system. The error can be seen in the below image:

If we read the error, the error tells us that sudo is not owned by the root user, which is different from saying that you are not a root user. The solutions to this error are discussed below.

Solution: Restoring the sudo Privileges

The first solution is to restore the sudo permissions using the following commands:

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

After that, run the system update command.

$ sudo apt update

In our case, this solution worked. And you can now use your “sudo” command.

If this solution does not work, you can use the alternate solution provided below.

Alternate Solution For Restoring sudo Privileges

The second solution is you can restore the sudo permissions by following the below simple steps:

Step 1: Start Single User Mode

First, start the system with single user mode, which can be done using the “init” command. In Linux, “init” is the earliest process on startup of the operating system and runs till the shutting down of the computer.

$ init 1

After executing the above command, the system will be restarted, and the following interface will appear:

While in rescue mode, follow the steps below.

Step 2: Remount Disk in Read-Write Mode

Then, open the terminal and execute the following command to remount the disk into read-write mode:

# mount -o remount /

Step 3: Return Privileges

After that, return (by switching the owner of the file to sudo) the permissions to the sudo file. To do so, execute the below command:

# chown root:root /usr/bin/sudo

Step 4: Fix Privileges

Now, fix the sudo permissions using the chmod command:

# chmod u+s /usr/bin/sudo

Step 5: Restart the System

Finally, reboot the system to exit the rescue mode and apply the changes:

# reboot

The “reboot” command will restart the operating system. These are all the possible solutions for the error “sudo: /usr/bin/sudo must be owned by uid”.

Conclusion

To resolve the “sudo: /usr/bin/sudo must be owned by uid 0” error in Linux, you need to restore the sudo privileges for that file. To do so, use “pkexec chmod a=rx,u+ws /usr/bin/sudo” command or “chown root: root /usr/bin/sudo” and “chmod u+s /usr/bin/sudo” commands. This post has briefly explained the possible reasons and solutions to the given error.