Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 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 error The administrator has set your shell to an illegal value

If I tried to sudo a command now I get

sudo: 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

share|improve this question
Nice 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. – NReilingh Mar 26 '12 at 3:33
up vote 6 down vote accepted

Kyle Jones' answer will definitely work, but have you tried running a Permissions Repair from Disk Utility? That might do the trick....

share|improve this answer
Are you sure? It did fix the problem – justinhj Mar 26 '12 at 4:07
@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. – NReilingh Mar 26 '12 at 4:42
@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 Mar 26 '12 at 13:39
I 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. – William Jackson Mar 26 '12 at 13:40
@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. – NReilingh Apr 12 at 15:20

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.

share|improve this answer
Don't you have to mount the fs first? – slhck Mar 26 '12 at 5:37
private/etc is on the root partition. – Kyle Jones Mar 26 '12 at 5:42
The 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. – Gordon Davisson Mar 26 '12 at 17:20
@Gordon Indeed. Thanks for pointing that out. I've edited the answer to include the needed mount command. – Kyle Jones Mar 26 '12 at 18:07
Upvote 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! – RARay Nov 9 '12 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .