Previous 1 2 3 Next 37 Replies Latest reply: Mar 13, 2016 9:02 AM by Tony.Collins Branched to a new discussion.
AidanBW Level 1 Level 1

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: VM025TDGB9S
Solved by Linc Davis on Jan 24, 2012 4:41 PM Solved

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.

Reply by Joshua Brown1 on Jul 23, 2013 5:42 PM Helpful

Or, you could go into Users & Groups in System Preferences, click Login Options, and change Display login window as: Name and password.  Go into /System/Library/CoreServices and open Directory Utility.  Click the lock in the bottom left of the screen and enter your password.  In the Edit menu, select Enable Root User and enter a password.

 

Log out.  When you get to the login screen, enter "root" (no quotes) as the user and the password you just selected.  Once everything has loaded, open the Terminal (located in /Applications/Utilities, or just press Command-Shift-U to open the Utilities window) and type:

 

chmod g+x /

 

Note the space between the x and the slash.

 

Logout.  Log back in as your usual user.  Everything should be working now. 

 

Go back into /System/Library/CoreServices and open the Directory Utility again.  In the Edit menu, select Disable Root User.  Close the program, and you're done. 

Reply by Camelot on Jan 24, 2012 2:23 PM Helpful

Well, the most obvious question is - what are the permissions on the file?

 

Since it's complaining about 'Permission denied', that would seem to be the first thing to check....

All replies

  • Camelot Level 8 Level 8
    expertise.macosx
    Mac OS X

    Well, the most obvious question is - what are the permissions on the file?

     

    Since it's complaining about 'Permission denied', that would seem to be the first thing to check....

  • Linc Davis Level 10 Level 10
    expertise.applications
    Applications

    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.

  • AidanBW Level 1 Level 1

    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

  • AidanBW Level 1 Level 1

    Looks like it's my only option.........

     

    Thanks,

    A

  • BobHarris Level 6 Level 6

    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
    
  • Fustbariclation Level 1 Level 1
    expertise.macosx
    Mac OS X

    Thank you for the suggestion. I found the fix - I re-installed Lion from the recovery system. It was the only thing that worked and, after that, Adobe stuff installed OK.

     

    It didn't fix, sadly, the graphics hang/crash kernel panic problem.

  • Adam Wenocur Level 2 Level 2

    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.

  • notafanboy2 Level 1 Level 1

    Adam's solution worked perfectly for me!

  • yb11 Level 1 Level 1

    it worked for me.

    I couldn't sudo after an upgrade to Lion from 10.6.

    it seems it also solved stability issues.

    precisely i added the execute permission to users within the administrative group, in a terminal

     

    > su  (type your root password)

    > chmod g+x /

    > exit

     

    I hope it is safe, feel free to correct me!

  • macktruck Level 1 Level 1

    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 ?

  • Adam Wenocur Level 2 Level 2

    Enter the commands yb11 posted above on a shell prompt (via the Terminal application).  If that doesn't solve the problem, adding these other commands may help:

    > chmod g+x /private

    > chmod g+x /private/etc

  • macktruck Level 1 Level 1

    Thanks!

  • maxschlehuber Level 1 Level 1

    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!

  • Adam Wenocur Level 2 Level 2

    Did you try opening the Terminal app and entering the chmod lines mentioned above?

Previous 1 2 3 Next