Skip to content

top MacOS command

The top command in MacOS is a powerful tool for monitoring system processes, CPU usage, and memory usage in real time. By using the top command, you can view a dynamic, continually updating list of processes running on your Mac, sorted by various criteria such as CPU usage, memory usage, and more. This allows you to quickly identify any resource-intensive processes that may be slowing down your system and take appropriate action. In addition, the top command provides useful information about system performance, such as load averages, uptime, and total number of processes. With its customizable display options and powerful features, the top command is an essential tool for system administrators, advanced users, and anyone looking to optimize their MacOS system performance.

top Syntax:

Terminal window
top [options]

Options:

OptionDescription
-hDisplay a help message
-oSpecify the sorting order
-qRun in secure mode (disables some commands)
-SCumulative mode (include child threads)
-sUpdate frequency in seconds
-uDisplay processes for a specific user
-lDisplay the average load
-nNumber of updates before exiting

Parameters:

ParameterDescription
usernameDisplay processes for a specific user by providing the username
PIDDisplay processes for specific Process ID (PID) by providing the PID
intervalSet the update frequency in seconds by providing the interval value
countSet the number of updates before exiting by providing the count value

top bash Examples:

Displaying CPU Utilization

Terminal window
top -o cpu

This command displays a dynamic view of the top processes on the system, sorted by CPU utilization.

Filtering Processes by User

Terminal window
top -u username

Filters the display to show only processes owned by a specific user, in this case, “username”.

Sort Processes by Memory Usage

Terminal window
top -o mem

Sorts the processes based on their memory usage, displaying the ones using the most memory at the top.

Displaying a Specific Number of Processes

Terminal window
top -l 5

Limits the number of processes displayed to 5, providing a concise overview of system activity.

Highlighting Processes Using a Specific User ID

Terminal window
top -pid username

Highlights the processes owned by the user with the specified user ID (PID).

Show Threads Instead of Processes

Terminal window
top -H

Switches the display to show individual threads within each process instead of the processes themselves.

top Command Help Center:

How can I monitor CPU usage with top in MacOS?

To monitor CPU usage with the top command in MacOS, use the following command:

Terminal window
top -o cpu

How can I display memory information using top in MacOS?

To display memory information using the top command in MacOS, run the following command:

Terminal window
top -o rsize

How do I sort processes by user with top in MacOS?

To sort processes by user using the top command in MacOS, use the following command:

Terminal window
top -o user

How can I change the update interval in top for MacOS?

To change the update interval in top for MacOS, use the following command:

Terminal window
top -s 5

How do I show processes in a tree view with top in MacOS?

To show processes in a tree view using the top command in MacOS, execute the following command:

Terminal window
top -O -p

How do I limit the number of processes displayed with top in MacOS?

To limit the number of processes displayed using the top command in MacOS, run the following command:

Terminal window
top -l 5

How can I display process threads with top in MacOS?

To display process threads using the top command in MacOS, use the following command:

Terminal window
top -H

How do I save the current top configuration in MacOS?

To save the current top configuration in MacOS, use the following command:

Terminal window
top -R

Applications of the top command

  • Monitoring system processes
  • Checking CPU usage
  • Analyzing memory usage
  • Viewing resource allocation
  • Identifying bottlenecks
  • Troubleshooting performance issues