Cannot run any sudo command
Solution 1:
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 use pkexec
as replacement to repair it:
pkexec chmod u+s,g-x /usr/bin/sudo
Now everything should be fixed again. Try the e.g. following command to check:
sudo echo "sudo works again! Yay! :D"
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 select root
, 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:
mount -o remount,rw /
chmod u=rwxs,g=rx,o=rx /usr/bin/sudo /usr/bin/pkexec
exit
Then reboot normally and test your commands.