Probably you aren't logged in as admin user or the admin entry in the sudoers file was removed accidentally.
So either log in as user with admin privileges or modify the sudoers file. The sudoers file located in /etc should show the following entries beginning at line 55:
##
## User privilege specification
##
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL
The last line denotes the ability of all admin users to act with root permissions by prepending sudo ...
in the command line – e.g. to edit the hosts file with sudo nano /etc/hosts
. Only the root user would be able to enter just nano /etc/hosts
and successfully edit the file.
The file /etc/sudoers can only be read or modified with root privileges!
If you are logged in as an arbitrary admin user you have to check the file /etc/sudoers. Since your admin vanished from the sudoers file you have to reboot to Recovery Mode and check/edit the file.
In Recovery Mode open in the menubar Utilities > Terminal. Enter mount
to get all mounted volumes:
/dev/disk2s1 on / (hfs, local, read-only)
devfs on /dev (devfs, local, nobrowse)
/dev/disk3 on /private/var/log (hfs, local, union, nobrowse)
/dev/disk4 on /Volumes (hfs, local, union, nobrowse)
/dev/disk5 on /private/var/tmp (hfs, local, union, nobrowse)
/dev/disk6 on /private/var/run (hfs, local, union, nobrowse)
/dev/disk7 on /System/Installation (hfs, local, union, nobrowse)
/dev/disk8 on /private/var/db (hfs, local, union, nobrowse)
/dev/disk9 on /private/var/folders (hfs, local, union, nobrowse)
/dev/disk10 on /private/var/root/Library (hfs, local, union, nobrowse)
/dev/disk12 on /Library/Preferences (hfs, local, union, nobrowse)
/dev/disk13 on /Library/Preferences/SystemConfiguration (hfs, local, union, nobrowse)
/dev/disk14 on /Library/Keychains (hfs, local, union, nobrowse)
/dev/disk15 on /private/var/tmp/RecoveryTemp (hfs, local, union, nobrowse)
/dev/disk0s2 on /Volumes/Data (hfs, local, journaled)
/dev/disk1s2 on /Volumes/Macintosh HD (hfs, local, journaled)
/dev/disk1s3 on /Volumes/Image Volume (hfs, local, read-only, journaled)
Search for the name of your main volume - usually it's related to disk0s1, disk1 or disk2 (in my example it's Macintosh HD: /dev/disk1s2).
Then enter:
/Volumes/volume_name/usr/sbin/visudo /Volumes/volume_name/etc/suoders
In my example that's:
/Volumes/Macintosh\ HD/usr/sbin/visudo /Volumes/Macintosh\ HD/etc/suoders
and modify the file according to your needs (i.e add the line %admin ALL=(ALL) ALL
if it's gone). You have to escape spaces in the volume's name with a \
!
BTW “username is not in the sudoers file. This incident will be reported.” might have the consequence that Santa Claus will evade your home next christmas, except you have launched some counter-measures in advance – like securing your Mac with a firewall.
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:
Open Terminal and run:
or, alternatively:
Open System Preferences.
Select Users & Groups.
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.
Right-click the account and select
Advanced Options...
.Locate the
Account name
property:Use that account name in
/etc/sudoers
. To edit the file, usevisudo
. For more information, check man visudo and man sudoers.