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
  • 110,243
cbll
  • 1,620

2 Answers2

3

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
  • 37,804
-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.

Thomas PEDOT
  • 119
  • 4