0

I am using Ubuntu 17.04.

By mistake, I have changed the ownership of sudo. So now I can't make any changes as the chown command I could use to fix it needs sudo.

If I use sudo I get

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Zanna
  • 72,312

3 Answers3

1

Your permission should be like following:

$ ls -l /usr/bin/sudo 
-rwsr-xr-x 1 root root 155008 May 29 15:49 /usr/bin/sudo

To do change it as default, please login with root user first and change the ownership for sudo "/usr/bin/sudo".

Eliah Kagan
  • 119,640
mAfiA
  • 11
1

If you really just changed the ownership of the sudo command--that is, the file /usr/bin/sudo--then you can fix this by using pkexec instead of sudo to run chown and change the ownership back. This command does that:

pkexec chown root: /usr/bin/sudo

pkexec will prompt you for your password (as would sudo if you were able to run it).

root: means the same thing as root:root, in case you had changed the group owner as well.

If you have changed the ownership of many more files besides /usr/bin/sudo, and in particular if you have changed the ownership of all files in /usr/bin (which would also happen if you changed permissions on / or /usr but passed the -R flag to chown, specifying recursive operation), then that will not be sufficient. But based on the description you have given in the question--that you have specifically changed the ownership of /usr/bin/sudo--running that one pkexec command should be sufficient.

Eliah Kagan
  • 119,640
0

Use a Live CD to mount your system's root partition and fix the permissions from there.

fkraiem
  • 12,813