28

When I type sudo <command> in terminal I get sudo: unknown uid 501: who are you? and when I type su I get su: who are you?

I think I must have changed super user permissions somehow on my personal machine. I'm not able to use sudo commands now, and I've not been able to find any helpful solutions. Do I have to do something with my /etc/passwd file? Can I even modify that?

s g
  • 5,289
  • 10
  • 49
  • 82
kashkar
  • 663
  • 1
  • 8
  • 22
  • Maybe click the Apple menu at top left of screen and then `System Preferences` then `Users` and add a new user with Administrator privileges and log in as him and correct things. – Mark Setchell Dec 06 '16 at 23:06

2 Answers2

46

FWIW - I simply had to install (via restart) the automatic updates that were downloaded and it was fixed. Logging out and back in didn't work.

It appears that simply restarting iterm2 may be sufficient, too, so that's probably a better place to start.

s g
  • 5,289
  • 10
  • 49
  • 82
  • My user didn't exist in /etc/passwd before or after, just good to know. – matt May 15 '17 at 14:42
  • 37
    I was able to resolve by exiting and restarting iterm2 which had running for weeks. – Puneet Lamba Aug 15 '17 at 01:24
  • 2
    Same for me. I hadn't restarted iterm2 in a week or two and I guess something got messed up. I quit and restarted it and composer updated fine. – ramijames Nov 27 '17 at 08:16
  • Even though I restarted my mac. I got the same error. So I exited the iterm tab and started a new tab. Check and found it fixed/working. :) Hope it helps others! – c g Apr 29 '18 at 02:54
  • 4
    Doesn't even need to restart iterm2: opening a new session (new tab) would work where the old tabs wouldn't. Still not understanding the cause though :( – jobwat Jul 08 '18 at 23:06
  • it was related to the environment variable `XPC_FLAGS=0x2`. Check https://apple.stackexchange.com/a/329668/13061 – jobwat Jul 08 '18 at 23:47
0

Have you enabled root user on your machine? Do these steps to check:

  1. Start System Preferences.
  2. Click Users & Groups.
  3. Click "Click the lock to make changes." and enter admin username and password (or just password if current user is an Admin).
  4. Click "Login Options".
  5. Click the "Network Account Server: Join" button.
  6. Click "Open Directory Utility".
  7. In the Directory Utility menu, click Edit.
  8. If there is a menu item that reads "Disable Root User", you are enabled as root user.
  9. If the menu item says "Enable Root User", click "Click the lock to make changes." and enter admin username and password (or just password if current user is an Admin).
  10. Select "Enable Root User".
  11. Set a root user password. It can be different from the admin password.

After you do this, sudo and su should work with the root user password.

Michael Domino
  • 409
  • 2
  • 9