I am running Big Sur on a MacBook Pro and am unable to run su
or sudo
in a terminal window despite being logged into an Admin (and Mobile) account. I always get the error: <username> is not in the sudoers file
.
Here is a transcript:
mac-947:~ spertus$ visudo
visudo: /etc/sudoers: Permission denied
mac-947:~ spertus$ sudo visudo
Password:
spertus is not in the sudoers file. This incident will be reported.
mac-947:~ spertus$ sudo su
Password:
spertus is not in the sudoers file. This incident will be reported.
mac-947:~ spertus$ sudo -s su
Password:
spertus is not in the sudoers file. This incident will be reported.
mac-947:~ spertus$ sudo -i spertus su
Password:
spertus is not in the sudoers file. This incident will be reported.
As suggested in a comment to macOS - User can perform admin tasks but cannot sudo, I tried granting Full Disk Access to the terminal app, but that didn't help. I also tried the answers in Cannot su to Admin on Big Sur without success.
This shows that I am logged into an account in the Admin group:
How can I add my account to the sudoers file (or otherwise run with root privileges)?
My question differs from I don't have administrator account on my mac because my account is in the Admin group, as shown in the screenshot.
%admin ALL=(ALL) ALL
", which means any member of theadmin
group is allowed to run any command as any user. One possibility is that there's something weird about your account that makessudo
think it's not in the admin group; creating a new admin account is a good way to test this. After that, looking at the /etc/sudoers file to see if that line is there would be the next thing I'd check./etc/sudoers
.