MacOS – How to solve “User is not in sudoers file, incident reported”

macossudo

I added

"Syammala Naidu" ALL=(ALL) ALL

to /etc/sudoers, rebooted and logged in as Syammala Naidu and run sudo -i. Sudo tells me: user not in sudoers file, incident Reported.

How can I fix this?

Best Answer

sudo exclusively uses account names, not the user's full name. As a hint, account names don't contain spaces, so "Syammala Naidu" is not correct.

To find out a user's account name:

  1. Open Terminal and run:

    id -un
    

or, alternatively:

  1. Open System Preferences.

  2. Select Users & Groups.

  3. If necessary, click the lock on the bottom left corner of the window and type an administrator's name and password to unlock the preference pane.

  4. Right-click the account and select Advanced Options....

  5. Locate the Account name property:

    enter image description here

Use that account name in /etc/sudoers. To edit the file, use visudo. For more information, check man visudo and man sudoers.

Related Question