2

I accidentally ran sudo chown -R -v myuser:myuser /, essentially transferring sudo to my own user by mistake. I meant to only take the current directory.

How do I recover from this? I stopped it after a few seconds, but running anything with sudo now gives me:

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Byte Commander
  • 107,489
cbll
  • 1,600
  • I've attempted it and I can't boot now. Stuck at spinning wheel. – cbll Dec 18 '17 at 20:28
  • It's stuck on "a start up job is running for hold until boot proceeds finishes up" been there for 5 minutes – cbll Dec 18 '17 at 20:35
  • 1
    I vote not a duplicate because this is about chown rather than chmod. Even though the solution (reinstall) may be the same and it's in the same general category of questions, people will be encountering this independently of the chmod issue and it may even have different symptoms or error messages. – thomasrutter Dec 18 '17 at 23:21
  • @thomasrutter "people will be encountering this independently of the chmod issue and it may even have different symptoms or error messages" isn't that the very reason to close it as a dupe? More signposts to the same problem? – muru Dec 19 '17 at 01:03

2 Answers2

4

There is no way to recover from this that is simpler than a reinstall. It is not the case that all system files simply need to be owned by a particular user, or root, or even that they follow a pattern. There are many files and directories throughout the system that rely on being owned by particular special purpose accounts.

In theory you could compare the ownership (user and group) of every file on your system to the ownership in a fresh install of Ubuntu, writing a script to replicate that ownership information. But even that is fiddly and prone to edge cases. Because this involves installing Ubuntu anyway, you may as well just reinstall.

thomasrutter
  • 36,774
-1

I see duplicates.

Have you tried https://askubuntu.com/a/471503/772996

  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.

But maybe to have a clean installation you should reinstall properly.