MacOS – Cannot Run Sudo After Mac Sierra Upgrade

macmacossudo

I tried running sudo in a terminal and was greeted with the error message:

sudo: unknown uid 501: who are you?

I tried doing an ls -l ~, and instead of seeing my user name in the file entries, I saw 501.

I think this might have happened in the process of upgrading Mac OS to Sierra; at least I think this is the first time I tried to run sudo since upgrading.

Best Answer

The problem was fixed by restarting the MacBook Pro.

However, when I first executed the restart, the system hung with a black screen. I then forced the power off (by keeping pressed the power button for several seconds), then turned it on. Then it worked.