Getting message "sudo: must be setuid root", but sudo IS already owned by root [closed]
Asked Answered
F

2

19

I'm trying to run sudo, and it's failing:

gregd@david $ sudo ls
sudo: must be setuid root
gregd@david $ which sudo
/usr/bin/sudo
gregd@david $ ll /usr/bin/sudo
-rwxr-xr-x 1 root root 165K 2012-05-16 00:25 /usr/bin/sudo*

Any suggestions on how to fix this?

Finedraw answered 22/5, 2013 at 1:58 Comment(0)
F
11

You have to be able to log in as root, but if you can you can run this

chmod u+s /usr/bin/sudo

And fix the problem

Finedraw answered 22/5, 2013 at 1:58 Comment(5)
What causes this problem?Lithology
I think it has to do with copying over your bin directory as non-root, then doing a chown on all the files to make them owned by root. But that's more or less a guessFinedraw
Interesting. That's at least second question from you answered by yourself in the same minute. Found a system abuse hole?Footbridge
When posting questions, StackOverflow asks if you have an answer you want to post as part of a Q&A. So I try documenting those problems I think others might care about, too.Finedraw
In OSX 10.6 I was able to solve this by running the Applejack program in single user mode.Erdmann
M
79

This problem is caused sometimes when the permissions of the file, /usr/bin/sudo get set to 777. If you do something like chmod -R 777 /usr/, you can do this. It effectively ruins sudo. Here is the solution if this is your problem, and the accepted answer doesn't work:

To fix:

Restart pc, press shift at boot menu.

This should bring up GNU GRUB (ie recovery mode) menu.

  • If this doesn't work, just restart mid boot and choose recovery mode when prompted on next launch.

Select the line which starts with Advanced options

Select the topmost version of the OS ending with ("recovery mode")

Press enter

In the following menu, go down to "Drop to root shell prompt"

Type the following:

mount -o remount,rw /

mount --all

chown root:root /usr/bin/sudo

chmod 4755 /usr/bin/sudo

restart

This should restore sudo privellages.

Maturation answered 10/10, 2013 at 21:56 Comment(8)
For me, logging out of the current user and logging in as the root user was enough to be able to run chown root:root /usr/bin/sudo and chmod 4755 /usr/bin/sudo. From there, I simply logged out of root and back in as my normal user and sudo worked without issue.Gemination
@Maturation Haha I'm a beginner too and did exactly what you did to break sudo: chmod -R 777 /usr/. The solution was easy to understand and it worked. Thanks!Neocene
@Maturation Worked like a charm, thanks, I was freaking out, thinking I had to reinstall linux mint. I did a chown on /usr/bin/* to get my github keys to work with my username instead of root. Lots to learn about linux administrationBenevento
u_vote for simplest disaster-fix ever.Navarrette
Worked like a charm... but... (I am running a debian jessie) I had to swap the restart with reboot.Bibliomancy
This was the best one which solved my problem.Bavardage
restart did not work for me so i did: /sbin/rebootCoast
Unfortunately this not only did not work for me, now after doing this suddenly my WiFi adapter disappeared from Ubuntu. So no sudo and no WiFi. I would appreciate any help...Alundum
F
11

You have to be able to log in as root, but if you can you can run this

chmod u+s /usr/bin/sudo

And fix the problem

Finedraw answered 22/5, 2013 at 1:58 Comment(5)
What causes this problem?Lithology
I think it has to do with copying over your bin directory as non-root, then doing a chown on all the files to make them owned by root. But that's more or less a guessFinedraw
Interesting. That's at least second question from you answered by yourself in the same minute. Found a system abuse hole?Footbridge
When posting questions, StackOverflow asks if you have an answer you want to post as part of a Q&A. So I try documenting those problems I think others might care about, too.Finedraw
In OSX 10.6 I was able to solve this by running the Applejack program in single user mode.Erdmann

© 2022 - 2024 — McMap. All rights reserved.