This question already has an answer here:
I have run following command accidentally
sudo chown [username] -hR /
Now sudo su getting error:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
How to Solve This?
|
This question already has an answer here: I have run following command accidentally
Now
How to Solve This? |
|||||||||
marked as duplicate by David Foerster, Eric Carvalho, WinEunuuchs2Unix, TheWanderer, terdon♦ Nov 21 '16 at 16:51This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||||||||
|
|||||||||
|
Back up your data and reinstall. This probably looks extreme but this isn't just You could try to mirror the owners off another install but there are cases ( Picking through that mess is going to take considerably longer than a clean install. This has had a couple of drive-bys from folks that don't understand the seriousness of the situation here. To them it looks like a big pile of unnecessary work, the sort of thing a rogue plumber or mechanic says to shake you down for a bigger job. If you've only changed the permissions on So please, don't be lazy about this. Filesystem permissions help keep you safe, fix them. |
|||||||||||||||||||||
|
|
As you'll read on this answer on SO, this problem is not as hard as people are making it. I got the
This does the trick and is much quicker and less painful than the "nuclear option" recommended in other answers. In case your root password is not set. You need to boot in Ubuntu's Recovery Mode to do this. |
|||||||||||||||||||||
|
Now I really think that re-installing would have been really a "nuclear option" |
|||||||||||||
|
|
Unfortunately, if you do not have a full backup, probably the best thing you can do at this point is to reinstall. Consider that you have changed all the files ownership to the same user, completely messing the security paradigm of your system.... If you search this site there are a lot of similar problems with chmod, as for example How can I recover from chmod -R a-wrx / command? |
||||
|
|
|
Had the same issue on my droplet on digital ocean.
Hope it helps. |
|||||||||
|
|
The above methods didn't work for me, because I couldn't "log back in as root" (unknown password) But I got a root shell by editing
After rebooting I was finally able to run
|
|||||
|
|
I was not able to edit
|
||||
|
|
|
I have changed /usr/lib/ to root owner but but sudo only executes with root login in the terminal. step one: su root step two: cd /usr/lib step three: chown -R root:root sudo and that is it. Just NOTE you have tu run su root every time you want to use sudo. |
|||||
|