CPU Usage in Mac Terminal
In this guide, we will show you how to monitor your Mac’s CPU usage using the Terminal application using top command.
Your Mac’s CPU (Central Processing Unit) is responsible for executing commands and running applications. Monitoring CPU usage can help you understand how much processing power is being used by apps and processes. If your Mac is running slowly or overheating, checking the CPU usage can reveal whether a specific application or process is using excessive resources.
On macOS, you can monitor CPU usage via the Activity Monitor, but if you prefer using the command line, the Terminal app provides quick and easy ways to do so.
Method 1: Using the “top” Command
The top
command is a powerful way to monitor your Mac’s CPU usage in real-time. It shows a live, continuously updating view of system processes, CPU usage, memory consumption, and more.
Follow these steps to use the top
command:
Step 1: Open the Terminal app. You can find it in Applications > Utilities or by searching for “Terminal” in Spotlight.
A Terminal window opens as shown in the following.
Step 2: In the Terminal window, type the following command and press Enter
:
top
Step 3: The top
command will display a real-time list of processes and their CPU usage. You’ll see a percentage of CPU usage for each process, along with other useful details like memory usage and system load.
Step 4: To quit the top
command, press q
on your keyboard.
Method 2: Using the “ps” Command
The ps
command allows you to view CPU usage for specific processes. You can combine this with other flags to customize the output and focus on specific details.
Follow these steps to use the ps
command:
Step 1: Open the Terminal app.
Step 2: In the Terminal, type the following command and press Enter
:
ps -A -o %cpu,comm
Step 3: The command will display a list of all running processes and their CPU usage, along with the command used to start each process.
Tip: You can filter specific processes using grep
. For example, to find CPU usage for the WhatsApp, type:
ps -A -o %cpu,comm | grep WhatsApp
You can also specify only a part of the process name. For example, let us find the usage of processes that have Whats
in their name.
ps -A -o %cpu,comm | grep Whats