How to Use Modern launchctl print Commands in macOS Terminal to Inspect User and System Daemons

In macOS system administration and endpoint troubleshooting, managing background agents, system daemons, and automated jobs is governed by Apple’s central init system: launchd. For years, administrators queried running services using the legacy launchctl list command. However, Apple completely overhauled the launchd domain architecture, deprecating legacy subcommands in favor of a unified domain target hierarchy.

The cornerstone of this modern interface is launchctl print. Unlike the legacy list command which returned flat tables with cryptic status integers, launchctl print provides deep, structured diagnostics into launchd domains, service states, Mach service IPC registrations, environment variables, and exit termination codes. This guide explains how to use modern launchctl print syntax to audit background services on macOS.

Understanding Modern launchd Domain Targets

Under modern macOS architecture, background services are isolated into discrete domain targets:

  • system/: System-wide daemons located in /Library/LaunchDaemons and /System/Library/LaunchDaemons (runs as root).
  • gui/<UID>/: User agents with access to GUI windowing servers, display hardware, and Keychain (runs as logged-in user).
  • user/<UID>/: Headless background user jobs that execute even when the user is logged out of GUI sessions.

Core launchctl print Commands

1. Printing User GUI Domain Status

To inspect all active services running in your current graphical login session (determine UID via id -u, typically 501):

launchctl print gui/$(id -u)

This command dumps active Mach port lookups, endpoints, and running launch agents.

2. Inspecting a Specific Service Daemon

To view deep diagnostic details for a specific background agent (e.g. an SSH agent or third-party backup service):

launchctl print gui/$(id -u)/com.example.backupagent

The structured diagnostic dump reveals:

  • state: Current process state (e.g. running, waiting, or spawned).
  • pid: Active Process ID (or - if idle).
  • last exit code: Exact POSIX return code or BSD termination signal (invaluable for diagnosing crash loops).
  • working directory: The runtime path where the service executes.
  • endpoints: Registered XPC and Mach IPC service names.

3. Printing System Domain Daemons (Root Services)

To inspect root-level system daemons (requires root privileges):

sudo launchctl print system/com.apple.metadata.mds

Diagnostic Output Reference Table

Field in print Output Significance Troubleshooting Value
state = running Process is actively alive in memory Confirms successful initialization
last exit code = 78 Configuration error (EX_CONFIG) Points to malformed configuration or plist keys
runs = 145 Cumulative spawn count High counts indicate excessive restart loops
throttled = 1 launchd backed off restart rate Service repeatedly crashed upon launching

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.