I am getting an error when trying to run any command in sudo mode.
Error:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
I found a number of questions and accepted answers on askubuntu.
But none of those solved my problem. Probably my case is different from them.
More information :
I tried to install utorrent
following the top voted answer of this question.
After extracting the .tz
file to /opt
I renamed the extracted file.
Since then I am facing this error.
I expect an answer which doesn't suggest me to reinstall the system.
If reinstalling is the only solution, I would have to backup everything I ever installed.
Best Answer
Simple fix, if you did not also mess up
pkexec
:The problem is that your
/usr/bin/sudo
has the wrong permissions set (-rwxrwxr-x
instead of correct-rwsr-xr-x
).Now, as the file is owned by root, you need root permissions to change its permissions. Usually, you would use
sudo
for this, but as it's broken, we have to usepkexec
as replacement to repair it:Now everything should be fixed again. Try the e.g. following command to check:
More complex fix, if you have also messed up
pkexec
:First, you need to boot your Ubuntu system in recovery mode.
You do this by rebooting and waiting for the GRUB menu to show up. This happens immediately after the BIOS finished its work and before Ubuntu starts to load. It will usually show up if you dual-boot with another OS, but if it does not, you have to hold the Shift key to let it appear. Select the menu point
Advanced options
and then chose the latest kernel version with the suffix(recovery mode)
. You will see another menu, where you have to selectroot
, which shows you a terminal with root access.More information on how to enter a root shell in recovery mode can be found here, please follow steps 1-7, then continue here.
Run the following commands in the root shell:
Then reboot normally and test your commands.