You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

sudo: can't open /private/etc/sudoers: Permission denied | sudo: no valid sudoers sources found, quitting

Hi,

I've had this problem before on an old machine and managed to fix it quite quickly, but the things I tried before don't seem to be working on this machine.


Basically, when I go in to Terminal and try running something with sudo, it just echoes:

sudo: can't open /private/etc/sudoers: Permission denied

sudo: no valid sudoers sources found, quitting


I also get the same message when booted in to Single user mode, thinking it might just have been an issue with my users id. I have already tried changing the file permissions, editing the sudoers file to add in my local users record etc...... but then it just gives me a different error message (eventually coming back to the above when I try changing something else to fix it).


I've run Applejack and Diskutility, but as expected they don't work either........


Any help would be much appreciated!- my new MacBook Pro won't even install anything requiring root permissions any longer, giving the same error message in the /var/log/install.log! :-(


As you can understand, I'm very upset because it is a new machine, and I have no idea what would have caused this to happen. The usual cause is editing the sudoers file without using visudo, but I can never recall doing that.


I need my root access back! 😟


Kind regards,

Aidan

iMac, Mac OS X (10.7.2), Hardware Serial: VM*****B9S

Posted on Jan 24, 2012 6:31 AM

Reply
42 replies

Jun 3, 2017 9:58 PM in response to Joshua Brown1

I used these instructions in El Capitan with excellent success. To understand the command better I found this response to the same question I had about it. I cheated and didn't read the man pages though.


https://askubuntu.com/questions/29589/chmod-ux-versus-chmod-x


My problem happened because instead of doing a drive replacement and restoration from a backup, I preferred to try a disk clone and simple swap. Each has respective challenges and benefits which aren't really appropriate to go into here. I'm just giving background as to HOW I came to this issue.


Many thanks to Joshua Brown for the well written resolution.

Jan 24, 2012 4:41 PM in response to AidanBW

Back up all data, if not already done. Boot from your recovery partition (command-R at startup) and reinstall Lion. If you upgraded from 10.6, you'll need the Apple ID and password you used to buy Lion from the App Store. Don't erase the boot volume; just reinstall in place. You won't need your backup unless something goes wrong.

Jan 25, 2012 4:27 AM in response to Camelot

Hi, thanks for the quick reply.

I've them set to 0440 (how they should be).


-------------------------------------------------------------------------------- ------------------------------------------------

ls -l /private/etc/sudoers

-r--r-----@ 1 root wheel 2869 24 Jan 13:17 /private/etc/sudoers


ls -le /private/etc/sudoers

-r--r-----@ 1 root wheel 2869 24 Jan 13:17 /etc/sudoers

0: user:a27aida allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity


id a27aida

uid=501(a27aida) gid=20(staff) groups=20(staff),403(com.apple.access_ssh),12(everyone),33(_appstore),61(locala ccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),100(_lpopera tor),204(_developer),402(com.apple.sharepoint.group.1)


-------------------------------------------------------------------------------- ------------------------------------------------

(Same output as in this post: https://discussions.apple.com/thread/2789552?start=0&tstart=0 )



Think I'm just going to have to go for the fresh install........ 😟 - as there are lots of other discussions to do with this topic, and none have been resolved.


Thanks for you help anyway!

A

Jan 25, 2012 5:26 AM in response to AidanBW

My Lion sudoers file looks like



/bin/ls -leO@ /private/etc/sudoers
-r--r-----  1 root  wheel  compressed 1275 Oct  8 01:19 /private/etc/sudoers


I think you can ignore the compressed.


I do not have any ACLs or other attributes on the file.


The contents of my sudoers file is


# 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

Nov 28, 2012 11:22 PM in response to Adam Wenocur

Adam Wenocur wrote:


I had this exact problem. It was due to the group execute bit being set to 0 on the root directory (not /private, not /private/etc). Be sure that both the owner and group execute bits of the directories containing /private/etc are all set to true, otherwise sudo won't be able to open the sudoers file.

I am having the same issue when installing Acrobat XI.

How exactly to you do what you mentionned ?

Apr 18, 2013 6:37 AM in response to Adam Wenocur

Hey, can you please help me. I just want to edit my host file to be able to downgrade my iphone. I did that without any problems a couple of weeks ago with "sudo nano /etc/hosts" , but now I get:


sudo: can't open /private/etc/sudoers: Permission denied

sudo: no valid sudoers sources found, quitting


I am Admin, I tried it with the root account, I fixed the access rights of the hdd and I changed, enabled and disabled file Sharing. My Macbook Pro is running with Mountain Lion.


I know my english is not the best. And I am not really into commanding with the terminal and that kind of stuff but i´ll try my best.


Please tell me a way how to edit my hostfile!


Thak you all for any suggestions!

sudo: can't open /private/etc/sudoers: Permission denied | sudo: no valid sudoers sources found, quitting

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.