Managing processes on macOS is a core skill for system administrators and power users. From listing processes to killing rogue tasks, this guide covers essential commands, detailed examples, and best practices for efficient process management.

Let’s dive in!

1. the ps Command: Listing Processes

The ps command provides a snapshot of active processes. Use it with specific flags to get detailed insights.

Comprehensive Process Listing

ps aux

Example Output:

Terminal output of the ps command, listing running processes with user, process ID, CPU and memory use, start time and command path.

Breaking Down the Flags

• a – Show processes for all users.

• u – Display process owner and resource usage.

• x – Include processes not attached to terminals.

Filtering Specific Processes

Find processes related to a specific app or service:

ps aux | grep TextEdit

Example Output:

texarxs 20260 0.0 0.1 413134080 91296 ?? S 3:37pm 0:02.12 /System/Applications/TextEdit.app/Contents/macOS/TextEdit

2. the top Command: Real-Time Process Monitoring

The top command displays a dynamic, real-time view of system processes.

Interactive Display

Simply run:

top

Sample Output:

Processes: 924 total, 3 running, 921 sleeping, 5064 threads 14:43:20

Load Avg: 3.18, 3.43, 3.42 CPU usage: 7.42% user, 4.49% sys, 88.8% idle

SharedLibs: 1134M resident, 216M data, 363M linkedit.

MemRegions: 0 total, 0B resident, 0B private, 14G shared.

PhysMem: 59G used (4249M wired, 912M compressor), 3903M unused.

VM: 390T vsize, 5533M framework vsize, 0(0) swapins, 0(0) swapouts.

Networks: packets: 5311658/6456M in, 2320291/1685M out.

Disks: 1855229/42G read, 2441613/44G written.

PID COMMAND %CPU TIME #TH #WQ #PORTS MEM PURG CMPRS PGRP

383 WindowServer 37.9 65:45.09 28 5 4356 1386M 563M+ 7056K 383

4811 com.apple.We 28.2 06:22.85 5 3 77 76M- 0B 0B 4811

0 kernel_task 19.2 32:23.85 867/16 0 0 13M 0B 0B 0

13718 com.apple.We 12.7 01:16.43 15 5 118 722M 29M 0B 13718

877 avconference 12.1 12:09.56 27 6 1407 297M- 235M+ 480K 877

Sort by Usage:

• CPU Usage:

top -o cpu

• Memory Usage:

top -o mem

3. Terminating Processes

kill Command

Use kill to terminate processes by PID (Process ID).

List Available Signals

kill -l

Common Signals

• 15 (SIGTERM) – Graceful termination (default).

• 9 (SIGKILL) – Immediate termination (forceful).

Termination Examples

• Graceful Termination:

kill -15 <PID> #Use ps aux or top to et the PID

• Forceful Termination:

kill -9 <PID> #Use ps aux or top to et the PID

killall Command

Terminate all processes with a specific name.

• Stop all instances of Google Chrome:

killall “Google Chrome”

• Interactive Force Stop:

killall -I “Microsoft Word”

pkill Command

Kill processes by name.

• Kill by Name:

pkill -f Safari

Pro Tips for Safe Process Management

  1. Verify Before Killing: Always check the process details before terminating.

  2. Use SIGTERM first: Attempt graceful termination before using SIGKILL.

  3. Avoid System Processes: Randomly killing system processes can destabilize your Mac.

  4. Monitor Resources: Use top or ps to identify problematic processes.

  5. Check man for all commands for more attributes

Bonus One-Liners

• Count Total Running Processes:

ps aux | wc -l

• List Top 10 CPU-Consuming Processes:

ps aux | sort -nrk 3 | head -10

These commands give you practical control over macOS processes.

Follow TexArxs on LinkedIn for more on macOS management and security.