Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 accidentalley deleted the sudoers file on Mac OS X; is there any way to recover it?
And once you've recovered it, how do you set it to mode 0440?

I presume not but I am desperate to get it back!

share|improve this question

I'm assuming you are trying to run a sudo command and it's giving you an error that /etc/sudoers does not have the correct permissions?

If you have previously granted your account Admin status, you should be able to fix the permissions through the GUI. Open the “/etc” folder in Finder (“Go” -> “Go to Folder…”), then open the sudoers file properties. Click the lock. Grant the admin group read/write, the system user read-only, the wheel group read-only, and the everyone group no access. The permissions should now be correct.

If you did not put yourself in the admin group, you will need to reboot OSX into single user mode and perform the command chmod 0440 /etc/sudoers.

share|improve this answer

If I understand your problem correctly then currently you don't have sudoers and you are trying to do sudo and its not working. In this case to get sudo working you can do the following :

  1. Create sudoers file in your home folder. You can find default content here sudores
  2. Open the “/etc” folder in Finder (“Go” -> “Go to Folder…”).
  3. Now copy sudoers file from home folder's to /etc folder via Finder.
  4. Prompt will come asking for password.
  5. Enter correct password and you are done.

To check sudo is running fine cd /etc and sudo vim sudoers. You should able to view sudoers file via vim editor. (Actually any read/write operation in /etc would require sudo command)

I know this is a bit surprising that even after not having sudoers, via UI we can do operations in /etc. But it worked for me :)

share|improve this answer

Your Answer


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.