I stupidly ran this command in Ubuntu 18.04:

sudo chown -R $USER:$USER /usr

Now I want to undo this but when I run:

chown -R root:root /usr

I get this error:

operation not permitted

And I can't run a sudo command and gives me this error:

/usr/bin/sudo must be owned by uid 0 and setuid bit set

How can I fix this?

marked as duplicate by Kulfy, Soren A, Arronical, Community May 16 at 21:22

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.

  • 1
    Reboot in recovery mode. – Jos May 16 at 8:22
  • @Kulfy The accepted answer to that question suggests to completely reinstall Ubuntu, which is overkill. – Jos May 16 at 8:30
  • Iam facing a deadline isn't any other way except reinstalling? – fjahan May 16 at 8:36
  • @Jos In what way is the accepted answer "overkill"? I checked and there are 13 different [UID,GID] pairs on my /usr. – waltinator May 16 at 13:33
  • @waltinator Hm. All four of my systems have only /usr/bin/at as the exception (daemon:daemon). But I realize I simply assumed that the whole of /usr was owned by root. – Jos May 16 at 14:44

You have to boot in maintenance (recovery) mode or with live CD / USB and mount the root volume.

  • Can you give more details of how to fix this in recovery mode? – fjahan May 16 at 8:30
  • See the link I provided. After step 9, enter your chown -R root:root /usr and reboot. – Jos May 16 at 8:59
  • That won't fix the files owned by root, but in one of the cricket, crontab, dip, mail, messagebus, mlocate, postdrop, shadow, ssh, tty or utmp groups. Many strange failures are in your future. – waltinator May 16 at 17:24

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