I'm using macOS catalina 10.15.7. I recently found out i cannot run sudo anymore, tried to run
sudo brew install nats-server, and got this message:
<myusername> is not in the sudoers file. This incident will be reported.
I got my username by
whoami. By running
id, i see
80(admin) was listed there.
Went to System Preferences -> Users & Groups, I saw my name (full name not my username) is listed under
Current User as
Followed other posts online, i was able to find /etc/sudoers.d folder and sudoers file, and right click
get Info, i added my username back to the permission list which allow me to read and write, the changes were made to both /etc/sudoers.d folder and sudoers file.
At one point of time i was able to run
sudo visudo /private/etc/sudoers and found out the line for admin was commented out, so i removed the comment to re-enable it, now the file has root and admin enabled, no other user:
root ALL = (ALL) ALL admin ALL = (ALL) ALL
and at the bottom of the file, i saw:
## Read drop-in files from /private/etc/sudoers.d ## (the '#' here does not indicate a comment) #includedir /private/etc/sudoers.d
after all these changes i still cannot run sudo:
sudo brew update sudo: 4294967295,2416387072,32767,0,0,0,0,0,0,0: invalid value sudo: error initializing audit plugin sudoers_audit sudo brew update Password: <my username> is not in the sudoers file. This incident will be reported
is admin and my username the same user? it should be, right? do i have to add my username in /private/etc/sudoers file separately?
id -un, it shows my username
ls -l /etc/sudoers, it shows:
-r--r-----+ 1 root wheel 1562 Jun 29 10:06 /etc/sudoers