How to fix /etc/ folder on Mac OS X
Solution 1
Kyle Jones' answer will definitely work, but have you tried running a Permissions Repair from Disk Utility? That might do the trick....
Solution 2
Reboot your Mac, holding down command-s
when you first hear the boot chime. Keep holding it down until you start seeing text on the screen. The system will boot into single user mode with a root shell.
mount -uw /
chmod a+x private/etc
will make /etc accessible again. Type exit
to the shell and the Mac will finish booting.
Related videos on Youtube
justinhj
Updated on September 18, 2022Comments
-
justinhj almost 2 years
I was following a tutorial which had this command to create a launchd.conf file in /etc/
sudo echo "some command" > /etc/launchd.conf
But it wouldn't work, I got permission denied after entering my admin password. It seemed like the permissions for the link were wrong, so I did
sudo chmod 755 /etc/
But now I can't load a terminal, I get the errorThe administrator has set your shell to an illegal value
If I tried to
sudo
a command now I getsudo: can't open /private/etc/sudoers: Permission denied sudo: no valid sudoers sources found, quitting Process *tramp/sudo root@localhost* exited abnormally with code 1
This is what the link /etc looks like, what should it look like, and how do I restore it?
lrwxr-xr-x 1 root wheel 11 Jul 21 2011 etc -> private/etc
/private/etc ...
drw-r--r-- 111 root wheel 3774 Mar 26 02:25 etc
edit: I'm using Mac OS X 10.7.3
-
NReilingh over 12 yearsNice one. :-P Always a better idea to elevate your own privileges than to change the permissions of your core directories. The permission denied you were getting was likely due to another problem.
-
-
William Jackson over 12 yearsThis is not what Repair Permissions is for.
-
justinhj over 12 yearsAre you sure? It did fix the problem
-
NReilingh over 12 years@WilliamJackson To my knowledge, it checks the filesystem's permissions against installed packages (perhaps from .pkg receipts). As /etc/ is a file installed with the core OS, I don't see why it wouldn't work.
-
slhck over 12 yearsDon't you have to mount the fs first?
-
Kyle Jones over 12 yearsprivate/etc is on the root partition.
-
William Jackson over 12 years@NReilingh I should have done more research before I spouted off. I was wrong and you are correct. I trivially edited the answer so I would be able to remove my downvote.
-
William Jackson over 12 yearsI also discovered that (at least in 10.7) you can find out if a file or folder will be fixed with Repair Disk Permissions by running this command in Terminal:
pkgutil --file-info /etc
, replacing/etc
with any location you want to check. Of course that is not much help when you can't load Terminal. -
Gordon Davisson over 12 yearsThe root partition is mounted readonly in single-user mode. You have to remount it for write access (
mount -uw /
) in order for the chmod command to work. -
Kyle Jones over 12 years@Gordon Indeed. Thanks for pointing that out. I've edited the answer to include the needed mount command.
-
justinhj over 12 yearsThis is a very handy feature, I'm glad it is there to help after I shoot myself in the foot :)
-
RARay over 11 yearsUpvote for the solution but also wanted to add that, in my case, it was the root that had the wrong permissions. So
chmod a+x /
worked for me. Thanks! -
mralexgray over 9 yearsFor google/posterity's sake.. This seems to have solved my issues with
sudo: unable to stat /etc/sudoers: Permission denied
(albeit without having to restart 😎 ) -
IgorGanapolsky about 8 yearsWhat in the world is
Permissions Repair
?? I cannot find it. -
NReilingh about 8 years@IgorG. Since this answer was written, Apple has removed permissions repair since it is no longer necessary, thanks to SIP. It was previously found in Disk Utility.
-
ivan_pozdeev over 7 yearsThe permissions aren't correct.
x
flag is needed to enter a folder. -
Francesco De Rosa over 7 years@ivan_pozdeev
755
sets theX
-flag for all users,755
meansrwxr-x-r-x
: permissions-calculator.org/decode/755 and of course everyone needs permission to access/
as otherwise you have access to nothing (as all files/folders, all mounted drives, yes even all devices are subfolders of/
and you don't have access to them without theX
flag)