I was getting below error while running command sudo -s after changing the permission to 777 of /usr/bin/sudo
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Ii solved this by below process:
Select your OS version in (recovery mode), and press Enter Key.
Ex : Ubuntu 14.04 (recovery mode)
It will bring you up another screen. Now select “Drop to root shell prompt” and press Enter.
It will load a command line at the bottom of the screen.
Now run each of the following commands.
mount -o remount,rw /
mount –all
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
restart
Now, I just want to understand why it was not working with 777 permission on /usr/bin/sudo
Please explain, thanks in advance.
I'm pretty sure this is a simple security feature where if the /usr/bin/sudo has different permissions to 755 it will become inaccessible. I couldn't find an article to confirm this so I'd say this is my guess. However you can find a lot of people asking the same thing an always everyone telling them to revert to 755 permissions
sudo
has the "setuid" bit (the4
inchmod 4755
). It means that when you executesudo
, you automatically get the privileges ofsudo
's owner, which is root. So any execution ofsudo
has root privileges, it's just that the first thing the "official" version does is asking for a password to determine it it can continue.If
sudo
is word-writable, then anyone can patch it to not check passwords or do other things, and so gain access to root privileges. Sosudo
must be kept R/O for everyone otherwise it should be considered as compromised.