I accidentally screwed up my sudoers file and I don't know where the changes I made are. I know how to get a new sudoers file to that location but the problem is that I don't know what is in it. So to help me, can you please first write the version of OS X you are running and then go into terminal. You have to type these commands that are separated by lines:

cd /etc

sudo cp sudoers ~

Then just open the sudoers file which is in your home directory and copy the text and put it in your reply.

  • 2
    There's no need to copy the file. sudo cat /etc/sudoers will reveal the content immediately. Also note that you'll be able to break your sudo installation if you don't use visudo. Commented May 14, 2012 at 3:14
  • 1
    Also check if you didn't change the permissions. Obviously, you should take more care in the future when messing with system files and working as root, which shows in the commands you gave us. There's no need to be root to copy the file somewhere else.
    – slhck
    Commented May 14, 2012 at 7:42
  • 4
    And since Mac OS X ships with various open-source components (including sudo), you could have found your defaults here: opensource.apple.com/source/sudo/sudo-60/src/sudoers Commented May 17, 2012 at 6:27

1 Answer 1


I'm running Mac OS X Lion 10.7.3.

Here's my sudoers file:

# sudoers file.
# This file MUST be edited with the 'visudo' command as root.
# Failure to use 'visudo' may result in syntax or file permission errors
# that prevent sudo from running.
# See the sudoers man page for the details on how to write a sudoers file.

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification
Defaults    env_reset
Defaults    env_keep += "BLOCKSIZE"
Defaults    env_keep += "COLORFGBG COLORTERM"
Defaults    env_keep += "__CF_USER_TEXT_ENCODING"
Defaults    env_keep += "LINES COLUMNS"
Defaults    env_keep += "LSCOLORS"
Defaults    env_keep += "SSH_AUTH_SOCK"
Defaults    env_keep += "TZ"
Defaults    env_keep += "EDITOR VISUAL"
Defaults    env_keep += "HOME MAIL"

# Runas alias specification

# User privilege specification
root    ALL=(ALL) ALL
%admin  ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel    ALL=(ALL) ALL

# Same thing without a password
# %wheel    ALL=(ALL) NOPASSWD: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now
  • 1
    May I add that the key is to edit the file through a GUI editor where OS X intercepts the permissions and allows you to edit the file. If you try and modify it through vim etc. you'll get thrown out because of the very thing you're trying to fix. Commented Mar 13, 2016 at 6:23
  • 1
    @Sridhar-Sarnobat vim will not allow a user to edit the sudoers file because to my knowledge the user is technically supposed to edit the file via visudo, since visudo parses the file before saving it to ensure you're not saving a file the system will not understand, which could potentially break things. I'm not entirely sure how OS X handles this, however. Commented Mar 13, 2016 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .