0

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: Screenshot of Users & Groups settings showing Ellen Spertus (spertus) in groups Admin, Mobile

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.

3
  • 1
    Using single-user mode as suggested in apple.stackexchange.com/a/218580/182183 should at least get you closer to the answer. You might also want to try creating a new user (with admin privileges) Nov 2, 2021 at 16:40
  • There are several possible causes here, and without some troubleshooting to find out what's wrong, it's impossible to say how to fix it. The /etc/sudoers file should have a line that says "%admin ALL=(ALL) ALL", which means any member of the admin group is allowed to run any command as any user. One possibility is that there's something weird about your account that makes sudo 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. Nov 4, 2021 at 3:35
  • EVen though your problem is slightly different than the linked question, the answer applies as well: you need to create a new admin user and then fix /etc/sudoers.
    – nohillside
    Nov 4, 2021 at 6:45

1 Answer 1

0

You can try create a new Admin User.

On Big Sur the following method works fine :

You boot in Recovery Mode. (cmd+r at boot) .

If Filevault is activated, from Disk Utility, you unlock/mount the System Volume giving the password. (right click on the system volume).

You quit disk utility, then on top menu you select Utilities/Terminal

I suppose the System Volume name is "Macintosh HD", the command is :

rm /Volumes/"Macintosh HD"/var/db/.AppleSetupDone

If no error message you reboot the Mac and then you will be invited to create a new administrator.

Then you may be could repair the currents Users.

2
  • Thank you, but I am already an Admin user. Nov 4, 2021 at 2:28
  • Sûre, but your admin has a problem with the sudoers file. Maybe a new user administrator created by the system can help you. Have you modify this file?
    – user415185
    Nov 4, 2021 at 6:20

Not the answer you're looking for? Browse other questions tagged .