Use system_profiler to get running services

Command: system_profiler SPServicesDataType

What it does: This command displays detailed information about all services running on the system, including network services, printer services, and other software-related services.

Example:

Let’s say you want to view a list of all services running on your MacOS machine. You can use the system_profiler command:

  1. Open Terminal on your MacOS machine.
  2. Type in the following command: system_profiler SPServicesDataType
  3. Press Enter to run the command.

Result: The output will display detailed information about each service, including its name, status, and other relevant details.

Tips:

  • To view more information about a specific service, use the -detail option followed by the name of the service (e.g., System). For example:
    • system_profiler -detail SPServicesDataType System
  • To view services only for a specific process or application, use the -process option followed by the name of the process (e.g., Finder). For example:
    • system_profiler -process Finder ServicesDataType
  • To stop or restart a service, use the launchctl command with the corresponding flags. For example:
    • launchctl stop com.apple.imagent

Trick:

To automatically disable or enable specific services when you log in or out of your account, you can create a custom AppleScript script and run it using the osascript command.

  1. Open Terminal and type in the following command: osascript -e 'tell application "System Events" to set enabled_services to {name of first process whose name contains "imagent"}'
  2. Replace imagent with the name of the service you want to enable or disable.
  3. Save this script as an AppleScript file (e.g., toggle_imagent.scpt) and add it to the login items in System Preferences.

This will automatically disable or enable the specified service when you log in or out of your account.

Note: Be aware that disabling or enabling system services may cause system instability or functionality issues if not used carefully.