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?

marked as duplicate by David Foerster, Eric Carvalho, WinEunuuchs2Unix, TheWanderer, terdon Nov 21 '16 at 16:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Note: When I had this issue, I had reinstalled the OS (Because at that time on-other answers exist and I can't wait more). So, Now new answers will be no longer supported from my side! – Pandya Jan 30 '15 at 12:18
  • Thanks to the tiny Warning posted under Option 1 here which I gladly ignored and ended up here! – Anand Rockzz Jun 30 '17 at 9:35
up vote 18 down vote accepted

Back up your data and reinstall.

This probably looks extreme but this isn't just sudo. You destroyed the permission structure of your entire filesystem. Some of the other answers can get sudo working, but ignoring the whole problem is inviting a later disaster.

You could try to mirror the owners off another install but there are cases (/var/ for example) that are highly dependant on what you've actually got installed. If you want to get a scale of the problem, I've actually had a crack at helping somebody fix this sort of issue before. The fix is manual, long and could easily leave your system insecure or broken.

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 /usr/bin/sudo, by all means, just fix that. But this question is about a total system change. Every file (save the runtime-only ones) are now owned by the user. Everything the user runs (eg browsers, browser exploits) could then overwrite system files, spy on you, extract any data. This needs to be corrected. Per above, this is difficult. The easiest way is a reinstall.

So please, don't be lazy about this. Filesystem permissions help keep you safe, fix them.

  • 3
    This should not be the accepted answer. Boot into recovery mode and run the commands in the following answer: askubuntu.com/a/471503/311767 – Tisch Jun 8 '17 at 9:35
  • 2
    @Tisch That answer fixes sudo. The question assumes the entire system is owned by $USER. Just repairing sudo leaves the rest of the system in a very vulnerable state. A reinstall is justified unless you want to spend hours trawling a working system to compare who system files should be owned by. – Oli Jun 8 '17 at 14:38
  • 1
    Bet this guy owns a PC "repair" shop in a mall – nodws Oct 21 '17 at 18:16
  • 3
    @oidualc Because it's the right answer. I'd already covered this in a previous comment and I've just added an edit. Filesystem permissions are a serious security feature. Don't be lazy about fixing this. To finish your analogy, your toe has gangrene and it's given you septicemia. You cannot see that in your delirious state, but trust me, I'm a doctor. – Oli Nov 20 '17 at 20:34
  • 1
    This answer is bogus. "su" then "chown root:root /usr/bin/sudo" – deepelement Nov 21 '17 at 0:35

As you'll read on this answer on SO, this problem is not as hard as people are making it. I got the sudo command working again without a reinstall by following these simple steps:

  1. Log out as the current user, then log back in as root.
  2. Execute chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
  3. Log out as root, then log back in as the current user.

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.

  • 15
    If you do not have a root user, restart and press Esc to enter the grub menu. There select Advanced options for Ubuntu and select recovery mode. Then select root and you can find yourself in the root shell. If you get an error that the filesystem is in read only mode, do: mount -o remount,rw / – George Oct 23 '14 at 2:25
  • 12
    Sure, that will fix sudo, but it isn't going to fix the dozens of other things that were broken. – psusi Jan 30 '15 at 20:57
  • 2
    Had same problem in my lxc container, additionally had to do this: chown root:root /usr/lib/sudo/sudoers.so && chmod 4755 /usr/lib/sudo/sudoers.so; chown root:root /etc/sudoers; chown root:root /etc/sudoers; – infro Jul 12 '16 at 5:40
  • 3
    using su root instead of sudo su, followed by the root password can save you some headache, if your ssh, or instead of going to grub. – Brian Thomas Aug 19 '16 at 1:03
  • 2
    in addition to what @infro said I also needed chown for /etc/sudoers.d, /etc/sudoers.d/README and /var/lib/sudo – Roman Bekkiev Sep 14 '16 at 8:59
  1. go to recovery mode by keep pressing Esc while booting the system.

  2. select root option in long list you can see after entering into recovery mode (it is actually root shell)

  3. type command - mount -o remount / (Or in recovery you can click on grub option. This helped me get read-write permissions on the file system. This basically updated the read/write mode on the file system since the command wasn't working for me initially)

    It will remount your file system in read and write mode.

  4. command - chown -R root:root /usr this command will change ownership from "user" to root again recursively

  5. now still i had problem with sudo command, so I again followed step 1,2,3 and executed chmod 4755 usr/bin/sudo

Now I really think that re-installing would have been really a "nuclear option"

  • This should be the accepted answer imo – cascading-style Jun 24 '17 at 18:02
  • Should be the accepted answer. Thanks sir. You just save my day! – gvsrepins Nov 24 '17 at 0:31

Had the same issue on my droplet on digital ocean.

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set. Below are command that ive execute and reboot after.

chown -R root:root /usr/bin/sudo
chmod -R a=rx,u+ws /usr/bin/sudo
chown -R root:root /usr/lib/sudo/sudoer.so
chmod -R a=rx,u+ws /usr/lib/sudo/sudoer.so

Hope it helps.

  • You don't need -R here. How did you manage to get permission to chown and chmod the files? – Zanna Sep 27 '16 at 5:02
  • without -R should be working..execute the command on my droplet console. – Marvee Lou Manriquez Ventures Sep 27 '16 at 7:27
  • @Zanna Digital Ocean images have root login enabled by default. – wjandrea May 9 at 15:37

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?

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

vi /etc/lightdm/lightdm.conf

autologin-user=root
greeter-show-manual-login=true

After rebooting I was finally able to run

chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
  • 1
    The "log in as root" originally said was actually "Reboot into recovery mode and pick the root shell". But as other comments have said, this only rescues the sudo. There are dozens and dozens of files that need the correct security which you have to manually fix. A reinstall is both quicker and more likely to fix everything. – Oli Jul 14 '15 at 8:14

I was not able to edit lightdm.conf file under running system. I fixed things like this:

  1. boot Ubuntu live usb
  2. mount the root partition in order to access /etc/lightdm/lightdm.conf on the installation
  3. sudo -H gedit /mnt/etc/lightdm/lightdm.conf and add the following lines from Anno2001's answer

    autologin-user=root
    greeter-show-manual-login=true
    
  4. reboot

  5. run command:

    chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo
    
  6. Change back default user in /etc/lightdm/lightdm.conf (you don't want to autologin as root every time, which would be very insecure and dangerous)

  7. reboot, and my system works fine again.

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.

  • except Ubuntu has disabled root access by default so you can't su root – Zanna Jan 2 '17 at 8:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.