Sudo broken on Ubuntu linux

claghorn
claghorn used Ask the Experts™
on
I get this when I try to do something as sudo.
sudo: must be setuid root

following some advice I went into recovery mode, and from command line as root
I tried:

chmod 4111 /usr/bin/sudo

and I could not do this, it said its a read only file system.

How can I get sudo back?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Just an update. I did manage to log in as a single user. root.
from there I saw that the permissions on /usr/bin/sudo is:
---x--x--x 2 root root

How do I make it ---s--x--x 2 root root?

This all started by the way because I was all of a sudden getting the message while doing something as sudo:

/etc/sudoers is owned by uid 1000, should be 0

I tried to fix that and thats why I'm here.

1000 is me though? I don't know how this happened to be honest.
If you boot into recovery mode, I believe you have to remount your hard drive installation before you can make any changes to it.
e.g.
# mount -o remount,rw /
the 'rw' makes it writeable, too.

Author

Commented:
Can you type the command I need.? I tried so many combinations of the above command but none have worked.
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Author

Commented:
# mount -o remount,rw '/usr/bin/sudo'

and I get:

mount can't find '/usr/bin/sudo' in /etc/fstab or /etc/mtab
So, what do you get from
# mount -o remount,rw /
?

How about the output from
$ cat /etc/fstab
?

Author

Commented:
# mount -o remount,rw /

gives no message and I enter the commands:

chmod 4111 /usr/bin/sudo
chown root:root /usr/bin/sudo

no message. ok so it worked?

but when I enter ls -l /usr/bin/sudo

I see:
---x--x--x 2 root root
not:
---s--x--x 2 root root (which is what I should see?)

when I go back and log in as normal and try something as sudo I get:

sudo: must be setuid root

So I think your advice so far has not worked. Thanks for help. Can you suggest some more things to try?

Author

Commented:
btw,

ls -l /etc/sudoers

returns:

-r--r----- 1 root root 723 Jan 31  2012 /etc/sudoers
How about the output from
$ cat /etc/fstab
?

Sanitize it if you think there's something private there (like, xxxx out passwords, et cetera).

Author

Commented:
ok, sorry to be a moving target but I ran:

chmod +s root /usr/bin/sudo

Then I saw that the permissions changed to the
---s--s--x 2 root root (that I was looking for)
Now sudo works again but I get the annoying message:

sudo: /etc/sudoers.d/README is owned by uid 1000, should be 0

This is what started happening in the very beginning.
Do you know how to get rid of that?

cat /etc/fstab returns:

# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sda1 during installation
UUID=xxxx /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=xxxx none            swap    sw              0       0


It would be nice to use su but when I try I get:
Password:
su: Authentication failure

I think this means su has no password. If I give it one. Then I can avoid this lengthy rebooting all the time.
su wants the root password, whereas sudo only needs the sudo user's password.

But to change the owner of a file, use
$ sudo chown owner:group /path/to/filename
owner and group can be the names or UIDs.

If you want to make the owner:group match another file's owner:group, use
$ sudo chown --reference=/path/to/otherfilename /path/to/filename

So you should be able to fix that message with
$ sudo chown 0:0 /etc/sudoers.d/README

And, of course,
$ man chown
gives all the options.

Author

Commented:
sudo chown 0:0 /etc/sudoers.d/README

The above worked. Thanks.

I am about to set the root's password because I want to use su.
I get prompted but when I just hit enter (since there is no root password set) I still get authentication error message.

I want to make sure sudo does not break again after I do this. If it does not break and su works then I'll be finished. And I'll close this out. Thanks again.

Author

Commented:
Actually sudo -i
seems to work.
I will not set a password for root.

Author

Commented:
I did this to fix it:
chmod +s root /usr/bin/sudo

Then I saw that the permissions changed to the
---s--s--x 2 root root (that I was looking for)
Now sudo works again but I get the annoying message:

sudo: /etc/sudoers.d/README is owned by uid 1000, should be 0

Then your suggestion of worked even further:
sudo chown 0:0 /etc/sudoers.d/README

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial