2

I have three admin accounts on one machine running El Capitan. The machine is a few days old. Whenever I try to run a sudo command, I'm asked for my password and told

accountUsername is not in the sudoers file.  This incident will be reported.

However, all the instructions I can find for adding a user to the sudoers file require having at least one user that has sudo privileges. I've tried

sudo visudo and sudo adduser username sudo - but obviously both of those require the user to be a sudo user.

I'm not sure how I ended up in sudo purgatory. The only thing I can think of is - my employer created two additional admin accounts and then removed admin rights from my original account.

All accounts have since been upgraded to have admin privileges and the problem still persists.

0

3 Answers 3

2

It sounds like your employer has disabled using sudo commands from any admin account, instead opting to include only specific users. This would mean only the employer's admin account would be able to use sudo. If you no longer have access to this account, you could boot into Single User Mode and run the visudo command to fix it. If they didn't remove the user from the sudoers list, you could also make a new admin account with the same shortname.

1
  • single user mode worked - but turns out I had to replace the whole sudoers file after borking it by opening it in Sublime Text.
    – gargantuan
    Dec 8, 2015 at 11:01
2

If that's possible, Recovery mode has a root terminal as one of the utilities. You can visudo from there, and add:

accountUsername    ALL=(ALL) ALL

Upon restarting, the user you listed will now be able to use sudo once again,

1

This situation was caused by opening the sudoers file in Sublime Text - which somehow resulted in a malformed sudoers file. So first of all, don't do that. I have since learned that you should only open the sudoers file with sudo visudo.

I replaced the file using visudo with a default sudoers file for my OS and version that I found online.

However, to do that you will need to log into single user mode (as per Austin or TheBro21's answers) or you could also enable root user temporarily while you fix this.

You must log in to answer this question.

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