How to Find Linux CPU Usage

If you do a lot of server administration, then you’ll no doubt have to do some performance testing at some point. If nothing else, you’ll want to know what is causing your server to slow down. Here’s how to find Linux CPU usage from the desktop or terminal.

Even when using the GUI, I like this method because it shows all the details I would want to know. Seeing a little chart is great and all, but what I really want to know are the details: which process is using up what percentage, what is its ID, who’s running it, as well as a summary.

I use the “top” command to see this information. It comes with practically every Linux distribution and can display all the active processes in a real-time prioritized list. In addition to CPU usage it shows memory usage, swap memory, cache and buffer sizes, and the process id (PID).

The top command from the Lubuntu GUI has highlights and different fonts

RHEL top command in a remote terminal window

To return to the command line, just press “Ctrl + C“.

There are a few other tools that offer more information or have different layouts, but they may not be installed by default. Some of these are “htop”, “lotop” (Linux Disk I/O), “monit”, “nethogs”, and there are many others. The problem with most of these is that they’re not installed by default, but can be downloaded with the yum package manager (apt-get if you’re on an Ubuntu flavor).

Alan is a web architect, stand-up comedian, and your friendly neighborhood Grammar Nazi. You can stalk him on the Interwebs via
Google+, Facebook and follow his ass on Twitter @ocmodshop.