sodcalculator

10 Tech How-To

Raspberry Pi CPU Usage: Check in Terminal or Desktop

Guide 10-54681 · Updated · Step by step

You can check Raspberry Pi CPU usage in the terminal with the top or htop command, or on the desktop using the built-in System Monitor or a panel applet. This guide covers both methods, explains what the numbers mean, and shows how to monitor or log usage over time.

Why CPU Usage Matters on a Raspberry Pi

The Raspberry Pi is a small, low-power computer, so its CPU is more limited than a typical desktop or laptop. High CPU usage can make the system sluggish, cause applications to lag, or even trigger thermal throttling where the CPU slows down to avoid overheating. Monitoring CPU usage helps you identify resource-hungry processes, check if a program is stuck in an infinite loop, or decide whether a workload is too heavy for the Pi’s processor.

Unlike a regular PC, the Pi’s CPU is often shared with the GPU (graphics processing unit) on the same chip. This means that video playback or GPU-accelerated tasks can affect CPU readings. Also, the Pi’s ARM architecture has a different performance profile than x86, so a process that uses 100% CPU on a Pi might be normal for that task, whereas on a desktop it could indicate a problem.

Checking CPU Usage in the Terminal

The terminal is the most direct way to see CPU usage on any Linux system, including Raspberry Pi OS. Here are the most common commands:

  • top – Shows a live, updating list of processes sorted by CPU usage by default. The header displays overall CPU statistics, including user, system, idle, and wait percentages. Press q to quit.
  • htop – An improved version of top with a color-coded interface, easier navigation, and the ability to scroll and kill processes directly. Install it with sudo apt install htop if not already present.
  • mpstat – Part of the sysstat package, shows per-CPU usage. Install with sudo apt install sysstat, then run mpstat -P ALL 1 to see each core’s usage every second.
  • vmstat – Shows system-wide CPU, memory, and I/O statistics. Run vmstat 1 to update every second.
  • sar – From sysstat, can log and report historical CPU usage. Useful for spotting trends over time.

For a quick one-time check, top is sufficient. For a more human-friendly view, htop is recommended. If you want to record usage to a file, you can use top -b -n 1 > cpu.txt to capture a single snapshot.

Reading the CPU Usage Numbers

Both top and htop display CPU percentages. In top, the line starting with %Cpu(s) shows:

  • us – User space: time spent running user processes.
  • sy – System: time spent on kernel processes.
  • ni – Nice: time spent on low-priority processes.
  • id – Idle: time with nothing to do.
  • wa – I/O wait: time waiting for disk or network I/O.
  • hi – Hardware interrupts.
  • si – Software interrupts.
  • st – Steal time (only relevant in virtualized environments).

The most important number is the idle percentage. If idle is 0%, the CPU is fully busy. If idle is 100%, it’s doing nothing. The total CPU usage is 100% minus idle. For example, if idle is 30%, the CPU is 70% used.

On a Raspberry Pi with 4 cores, top shows a single overall percentage. To see per-core usage, press 1 in top or use htop which shows a bar for each core by default. Note that a single-threaded process can max out one core while others are idle, making overall usage look low (e.g., 25% on a 4-core Pi).

Checking CPU Usage on the Desktop

Raspberry Pi OS (based on Debian) includes a graphical System Monitor. You can find it in the menu under System Tools or by searching for “System Monitor”. It shows graphs for CPU, memory, network, and disk usage, and lists running processes with their CPU consumption. You can sort by CPU to see which process is using the most.

If you prefer a small always-visible indicator, you can add a panel applet. Right-click on the top panel, choose Add/Remove Panel Items, then click Add and select CPU Monitor or System Monitor (depending on your version). This places a small graph or percentage in the panel that updates in real time.

For a more customizable desktop widget, you can install Conky, a lightweight system monitor that can display CPU usage, memory, and more on the desktop background. Install it with sudo apt install conky and configure it with a text file.

Common Problems and Misconceptions

One common misconception is that CPU usage should always be low. In reality, a busy Pi is often fine as long as it’s not overheating or making the system unresponsive. Another issue is misinterpreting the wa (I/O wait) value. High I/O wait means the CPU is waiting for disk or network operations, which can make the system feel slow even if CPU usage is low. This is especially common on older Pi models with SD card storage.

A frequent problem is seeing 100% CPU usage from a single process like python or java. This could be a legitimate heavy task, but it might also be a runaway process. You can kill it with kill <PID> or pkill <name> in the terminal. In htop, you can select the process and press F9 to kill it.

Another issue is thermal throttling. If the CPU gets too hot (above 80°C), the Pi reduces its clock speed, which can make CPU usage appear high even when the system is idle. Check the temperature with vcgencmd measure_temp (on older models) or cat /sys/class/thermal/thermal_zone0/temp (on newer models, divided by 1000 to get °C).

Monitoring CPU Usage Over Time

For logging CPU usage to a file, you can use a simple loop in the terminal:

while true; do echo "$(date) $(top -b -n 1 | grep '%Cpu')" >> cpu.log; sleep 5; done

This appends a timestamp and the CPU line every 5 seconds. To stop it, press Ctrl+C. Alternatively, use sar from sysstat to collect historical data. First, enable collection by editing /etc/default/sysstat and setting ENABLED="true", then restart the service. After a day, you can view a summary with sar -u.

For a more visual approach, you can use rrdtool or a Python script with matplotlib to plot CPU usage over time. But for most users, the built-in tools are sufficient.

Alternatives and Advanced Tools

If you need more detailed information, there are several advanced tools:

  • perf – Linux performance analysis tool that can measure CPU performance counters. Install with sudo apt install linux-perf.
  • atop – A system monitor that logs all processes and system resources. Install with sudo apt install atop.
  • glances – A cross-platform monitoring tool that shows CPU, memory, disk, and network in a single terminal window. Install with sudo apt install glances.
  • netdata – A real-time, web-based monitoring solution that runs as a daemon and provides a beautiful dashboard. Install from their repository or via curl script.

For headless setups (no monitor), you can access the desktop remotely via VNC or use a web-based tool like netdata to view CPU usage from another device. This is especially useful for servers or IoT projects.

Frequently Asked Questions

How do I see CPU usage per core on Raspberry Pi?

In top, press the 1 key to toggle per-core statistics. In htop, the bars at the top show each core’s usage by default. You can also use mpstat -P ALL 1 to display per-core usage continuously.

Why is my Raspberry Pi CPU usage always 100%?

Check which process is using the most CPU with top or htop. Common culprits include background updates, a stuck process, or a heavy application. If the system is idle but CPU is still high, check for malware or a runaway process. You can also look at I/O wait and temperature, as these can affect perceived CPU usage.

What is a normal CPU temperature for a Raspberry Pi?

Under normal load, the CPU temperature should be between 45°C and 60°C. If it exceeds 80°C, the Pi will throttle to prevent damage. You can check with vcgencmd measure_temp or by reading the thermal zone file. Ensure proper ventilation and consider a heatsink or fan if temperatures are too high.

Can I check CPU usage without installing anything?

Yes, the top command is pre-installed on Raspberry Pi OS and most Linux distributions. It shows live CPU usage and process list. The desktop System Monitor is also included by default in the full version of Raspberry Pi OS.

How do I log CPU usage to a file for later analysis?

Use a simple bash loop with top or sar as described above. For example, top -b -n 1 >> cpu.log captures a single snapshot. To log continuously, use a loop with a sleep interval. For more robust logging, install sysstat and enable sar collection.

Does CPU usage affect power consumption on a Raspberry Pi?

Yes, higher CPU usage generally increases power consumption, but the difference is small. A Raspberry Pi draws about 3-5 watts at idle and up to 7-8 watts under heavy load, depending on the model. If you’re powering it from a battery, reducing CPU load can extend runtime.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →