2

In an effort to shut down the httpd server, I was going to execute this command:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Instead this was executed:

sudo launchctl unload -w /System/Library/LaunchDaemons

The result was that my MacBook just stopped completely and can’t boot. Is it possible to revert it with the following command?

sudo launchctl load -w /System/Library/LaunchDaemons/

But I don’t know what was on and off.

So I need help. How do I restore it? I tried to alt-boot, got into Mountain Lion's recovery options and reinstalled the system, but with the same result. Is the terminal in the recovery tool to any help?

Is this setting saved in a file I can restore from Time Machine?

2 Answers 2

2

You should be able to fix this in single-user mode. Restart the Mac while holding the Command and S keys; it'll start into a full-screen command-line environment, with none of the usual daemons even trying to run. As usual, the first two things to do in single-user more are to check/repair and mount the startup volume. To check/repair it, run the command /sbin/fsck -fy and wait for it to finish. If it prints " The volume was modified ", run it again and keep running it until it finishes with "** The volume appears to be OK." Once the startup volume is OK, mount it with /sbin/mount -uw /

Once that's done, run the command:

rm /var/db/launchd.db/com.apple.launchd/overrides.plist

(Note: type this command very carefully. If you thought the damage from mistyping that launchctl command was bad, you haven't seen what a garbled version of this command could do!)

Finally, run the command reboot and the system should restart normally, with all of the system LaunchDaemons set back to their default states.

2
  • Restored everything. The machine booted like nothing had happened. Dec 31, 2012 at 9:39
  • I've not had long term luck messing with /var/db and instead like to install to a clean drive and migrate things over. It is hard to know which agents are per user, per system and more. At least that overrides.plist is not binary and you can inspect it without plutil :-)
    – bmike
    Dec 31, 2012 at 14:58
0

I would just quit and save any work you can and then reboot at that point.

 sudo shutdown -r now

If you did manage to unload all the daemons and services, I would install a clean OS onto an external drive (using Mountain Lion recovery) and then migrate the settings over. You also should be able to restore a Time Machine backup, but that would need an erase and then an install, so I prefer to spend the extra $$ on an external hard drive and then after testing the clean OS, migrate your data over.

This has a bonus of testing your hardware for failure and delays when you erase the faulty data/drive if you lack a current backup or are not sure you can recover from a backup.

2
  • Reinstall of the OS onto the same disk did not solve the issue. Dec 31, 2012 at 9:32
  • I know you said a reinstall of the OS on the same disk didn't work, but that's probably because of the bad data not being wiped. Without installing to a new clean drive or to an erased drive, you won't be able to tell if you had a coincidental hardware failure or it was bad data being re-applied to the new OS reinstall. Installing a clean OS onto an external drive lets you test a clean OS on a clean drive easily.
    – bmike
    Dec 31, 2012 at 13:24

You must log in to answer this question.

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