When I try to enter commands into the terminal I get this message "myusername is not in the sudoers file. This incident will be reported." It started when I tried to edit my host-file. What do I do to fix this? I want to spoof my MAC address. I have the newest version of OS X. myusername is not actually my real username.
MacOS – When I enter commands in the terminal I get: “username is not in the sudoers file. This incident will be reported.”
macosterminal
Best Answer
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:
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 withsudo nano /etc/hosts
. Only the root user would be able to enter justnano /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: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:
In my example that's:
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.