Apparently I can't sudo on my Mac any more.
Piers-MacBook-Air:~ piersb$ sudo ls
Password:
Sorry, user piersb is not allowed to execute '/bin/ls' as root on Piers-MacBook-Air.local.
Piers-MacBook-Air:~ piersb$
It worked before the most recent El Capitan update (the upgrade to 10.11.4), and I'm on a mid-2013 MacBook Air. The account is an admin account, and I was able to sudo before then. My first thought was to add myself into /etc/sudoers but, haha, of course you need sudo for that.
Piers-MacBook-Air:~ piersb$ ls -al /etc/sudoers
-r--r----- 1 root wheel 272 5 Apr 11:15 /etc/sudoers
Piers-MacBook-Air:~ piersb$ groups
staff com.apple.sharepoint.group.1 everyone localaccounts _appserverusr admin _appserveradm _lpadmin _appstore _lpoperator _developer com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh
I'm able to create a new admin user, but that user has the same problem.
Piers-MacBook-Air:~ testuser$ sudo ls
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
Password:
Sorry, user testuser is not allowed to execute '/bin/ls' as root on
Piers-MacBook-Air.local.
So. How do I give myself access to sudo again? And is this a common problem?
Best Answer
Looks like it only co-incidentally appeared at the 10.11.4 update; the problem was actually when I installed vagrant. Somewhere along the line either I or a script I used overwrote /etc/sudoers with the following rather than appending it:
So /etc/sudoers was toast. Here's how to fix it if this happens to you.
You should now be safely editing /etc/sudoers. Or at least as safely you as you can do anything while logged in as root.
Replace whatever nonsense you have in there with a properly safe file. Here's the one I used:
exit
to get out of the root shellAnd - huzzah! - your sudo command should be back up-and-running again.