MAC OSX BOOT sequence ( launchd )

Os x boot sequence  : what is launched at startup of your Mac can be easily see :
System Preferences” -> “Users & Groups” -> “Login Items”

OSX Login Items (preference panel)
OSX Login Items (preference panel)

However not everything is there.

#1 MAC Boot sequence

Who knows boot sequence of Linux will find similar the MAC OSX startup sequence…
The sequence :
OSX boot sequence
OSX boot sequence

In the “power on step (as you probably figured out) EFI selects the right device to use : you can overwrite this pressing “options” key during startup. Btw after that BootROM, EFI, Boot Loader and  Kernel aall of them have done their job the control passes to launchd process.
Launchd is in fact the first process that Kernel starts (PID is 1) and it starts the “user space” boot sequence

busycrack$ ps aux | grep launchd
root               1   0.0  0.1...0:07.95 /sbin/launchd
So Launchd has in charge to start System and Users daemon/agent basing its task on plist files here :
~/Library/LaunchAgents Per-user agents provided by the user
/Library/LaunchAgents  Per-user agents provided by the administrator
/Library/LaunchDaemons System-wide daemons provided by the administrator  
/System/Library/LaunchAgents    Per-user agents provided by Mac OS X
/System/Library/LaunchDaemons  System wide daemons provided by MAC OS X

For example in my home directory I have:

busycrack$ cd ~/Library/LaunchAgents && ls -ltra
total 24
-rw-r--r--@  1 busycrack  staff   806 Jul 11 20:59
-rw-r--r--   1 busycrack  staff   697 Jul 20 22:25 com.*****.XXXXX.YYYYYYY-1.0.plist
drwx------@ 55 busycrack  staff  1870 Jul 28 18:06 ..
-rw-r--r--   1 busycrack  staff   606 Jul 28 18:40 de.metaquark.appfresh.plist
Launchd is controlled by command launchctl … below some notes

#a) list all with command “lauchctl list”

busycrack$ launchctl list 
-       0       de.metaquark.appfresh
581     -       [0x0-0x4b04b].de.metaquark.appfresh
-       0

Where :

PID Last Exit Status Job Label
581  – [0x0-0x4b04b].de.metaquark.appfres
–   0 de.metaquark.appfresh

#b) get details:
lauchctl list de.metaquark.appfresh”

busycrack$ launchctl list de.metaquark.appfresh
        "Label" = "de.metaquark.appfresh";
        "LimitLoadToSessionType" = "Aqua";
        "OnDemand" = true;
        "LastExitStatus" = 0;
        "TimeOut" = 30;
        "ProgramArguments" = (

#c) list all daemons not by apple :
launchctl list | grep -v”

In order to discover not apple daemon generally  :
busycrack$ launchctl list | grep -v
PID     Status  Label
216     -       com.MadCatz.SmartTechnology
-       97      com.adobe.CS5ServiceManager
-       0
Note : try also “sudo launchctl bslist | grep -v apple”

#d) remove : “launchctl remove de.metaquark.appfresh”
#e) disable  : “launchctl unload -w ~/Library/LaunchAgents/…”

How disable Deamon/Agent at startup?

You can remove .plist file from directory or you can use launchctl:
launchctl unload -w ~/Library/LaunchAgents/
In theory this should unload and disable the service adding Disabled Key :
less ~/Library/LaunchAgents/

 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
  <plist version="1.0">
Really what happen is that file remains unchanged and what change is overrides.plist.
File overrides.plist is present in : 
    or in directory :
Position depends by domain of daemon/agent  if it is System or Per-user.
Note peruser.501 : 501 ( is id of user :
busycrack$ id
uid=501(busycrack) gid=20(staff) groups=20(staff)...
Btw file overrides.plist  reports values which are overriding the values in main .plist :
launchctl load -w ~/Library/LaunchAgents/
less /private/var/db/launchd.db/
launchctl unload -w ~/Library/LaunchAgents/
less /private/var/db/launchd.db/

However for this and much more things :

  • man launchd
  • man launchctl

#2 Bonus

2.1) try command :  sudo launchctl bstree -j

Customizing Login and Logout :
2.2) you can check present of login script with command : LoginHook

defaults read LoginHook

Script (if present) which is attached to user login… more details :

2.3) logout script : LogoutHook

defaults read LogoutHook

Script (if present) which is attached to user logout

#3 App GUI for lauchdctl

lingon : 

User Review
5 (1 vote)