The LEGOers

Q: Admin account does not have sudo?

Hello, apparently my one and only user account (excluding the root account etc.) is not in the sudoers file. How should I fix it such that I can access sudo again?Screen Shot 2016-09-03 at 10.04.35 PM.png

MacBook Pro with Retina display, OS X El Capitan (10.11.5), Soon Running macOS Sierra beta

Posted on Sep 3, 2016 7:08 AM

Close

Q: Admin account does not have sudo?

  • All replies
  • Helpful answers

  • by Barney-15E,

    Barney-15E Barney-15E Sep 3, 2016 7:23 AM in response to The LEGOers
    Level 8 (49,722 points)
    Mac OS X
    Sep 3, 2016 7:23 AM in response to The LEGOers

    The default sudoers file has the "admin" group set for using sudo.

    You can check the membership of the admin group with Directory Utility.

    On the Directory Editor tab, choose Groups from the Viewing Popup menu.

    Select the Administrators group.

    Look for the GroupMembership line and click the triangle to disclose the contents.

    If your user is not in that group, you can try to add it. You must first click the Padlock to authenticate.

     

    If you are already in that group, or you cannot authenticate, you may have a corrupt sudoers file.

    You may be able to create a new admin user that can use sudo. If so, you may be able to then repair it from that user.

  • by Barney-15E,

    Barney-15E Barney-15E Sep 3, 2016 7:42 AM in response to The LEGOers
    Level 8 (49,722 points)
    Mac OS X
    Sep 3, 2016 7:42 AM in response to The LEGOers

    If you are in the admin group, then you try creating a new admin user.

    Log into that user and run this in the terminal

    sudo visudo

    Opening it and saving it may correct the problem. However, if it doesn't open or filled with garbage characters, then you might need to edit it.

    If that is the case, I can show you what it should look like.

    You can learn to edit in Vim by running this command in the Terminal:

    vimtutor