Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – Sebastian Stumpf May 14 '12 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 May 14 '12 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 – Sebastian Stumpf May 17 '12 at 6:27

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 += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
Defaults    env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
Defaults    env_keep += "LINES COLUMNS"
Defaults    env_keep += "LSCOLORS"
Defaults    env_keep += "SSH_AUTH_SOCK"
Defaults    env_keep += "TZ"
Defaults    env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
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
share|improve this answer
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. – Sridhar-Sarnobat Mar 13 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. – Huskehn Mar 13 at 22:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.