0

I changed ownership away from root in /usr/local/bin and in /usr/bin.

However, now I am unable to use sudo. The message I get when trying to use sudo is:

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

I have looked online and have tried the solutions using chown but nothing works.

When I type this command:

ls -l /usr/bin/sudo

I get the output:

-rwsr-xr-x 1 swirlydino root 136808 May 29 06:32 /usr/bin/sudo

Also when I type this command:

ls -ld /usr /usr/bin

I get this output:

drwxr-xr-x 10 root  root  4096 Jun 14 10:15 /usr
drwxr-xr-x  2 datax root 36864 Aug 18 14:26 /usr/bin

So, how can I change back the ownership from swirlydino to root?

troylatroy
  • 1,275
  • 1
  • 11
  • 21

1 Answers1

3

Sudo must be owned by root, and have the set uid bit set. The set uid bit of the permission mask effectively makes the binary run as the user that owns it, no matter who invoked it. Thus sudo can change uid of whatever process it spawns.

By changing ownership on /usr/bin you've pretty much hosed your installation. A lot of binaries rely on suid, and having them owned by the user anyway opens you to a lot of interesting attacks.

https://en.wikipedia.org/wiki/Setuid has a good explanation of how suid works in detail.

At this point the best tip is to reinstall ubuntu... :)

vidarlo
  • 22,691