Add a User to the Sudoers File in Mac OS X

Adding users to the sudoers requires the usage of vi, which can be fairly confusing if you’re not accustomed to it. For the unfamiliar, we’ll outline the exact key command sequences to edit, insert, and save the file in vi, follow the instructions carefully.

  1. Launch Terminal and type the following command:
    sudo visudo
  2. Use the arrow keys to navigate down to the “#User privilege specification” section, it should look like this:
    # User privilege specification
    root ALL=(ALL) ALL
    %admin ALL=(ALL) ALL
  3. Put the cursor on the next empty line below the %admin entry and then press the “A” key to insert text, then type the following on a new line, replacing ‘username’ with the users short name of the account you wish to grant privilege to (hit tab between username and ALL):
    username ALL=(ALL) ALL
  4. Now hit the “ESC” (escape) key to stop editing the file
  5. Hit the : key (colon) and then type “wq” followed by the Return key to save changes and exit vi


You should be good to go, you can cat the sudoers file to be certain the file was modified:

Leave a Comment