top
(pictured below... above is btop) is the first utility everyone recommends to monitor Linux (or any form of UNIX, including macOS) resource usage. It's efficient, available almost everywhere... but it's also a bit basic. It shows essential metrics, but looks like it's from the 80s. There are ways to brighten it up, like highlighting active processes or changing color schemes, but it's not the only game in town!
Nowadays, there are a lot of modern monitoring tools—and some not so modern, but immensely useful—to choose from. This blog post will run through some of the ones I rely on most often. Let me know in the comments if you use any others I didn't cover!
Contents
If you'd like to see all these tools in action, check out the video that goes along with this blog post, embedded below:
s-tui
# Install on Debian/Ubuntu Linux
apt install -y stress-ng s-tui
If I want to quickly observe the system's CPU frequency and temperatures while running a stress benchmark, this is by far the best way.
I originally discovered this tool through ServeTheHome—Patrick uses it and displays it on the giant screen behind him to monitor core to core stability when running a system under load.
It has two basic modes, 'Monitor' and 'Stress', and while running in Stress mode, it will use stress
or stress-ng
to stress all CPU cores (you can configure stress
options within s-tui
's configuration).
I've used it on Linux and macOS, and it seems to pick up the right temperature sensors on most hardware, even exotic systems like the AmpereOne!
htop
sudo apt install htop
htop is often installed by default (e.g. on Raspberry Pi OS), and is like top, but focuses visually on CPU metrics more than memory. It provides more visual indication of system load through bar graphs, and it's usually a tossup whether I choose htop
or top
.
atop
sudo apt install atop
atop
breaks out a lot of critical performance metrics into a dizzying array of metrics, with a process list below. There are two features I like about atop
that draws me to it instead of other tools when I'm debugging hardware bottlenecks:
First, it uses color sparingly to indicate resources reaching saturation (e.g. 90% of disk, memory, or CPU usage turns that metric red).
Second, it breaks out IRQ consumption, network packets in and out, and some other metrics that are either hidden or buried in other tools. This tool has been especially helpful when troubleshooting bottlenecks like network file copy slowdowns, which sometimes are affected by CPU core affinity, PCIe bottlenecks, or disk IO (or a combination of all!).
iftop
sudo apt install iftop
If I'm just focused on bandwidth monitoring—seeing how much data is going through a network interface, there's no simpler tool than iftop
. It shows total bandwidth over the interface, along with a running total of download and upload size. Then it lists every connection with traffic up and down, with a simple bar graph display for each.
iotop
sudo apt install iotop
What iftop
is for network bandwidth, iotop
is for disk bandwidth.
The nice party trick is it also breaks out the disk IO by process, so if you are experiencing slow disk access, or want to see what processes are hogging a drive, this is the quickest way to get at that info.
If you want to get even fancier, sysdig
(sudo apt install -y sysdig
) comes with a console UI csysdig
which lets you dig directly into processes by volume of data written or ops! Very handy.
nvtop
sudo apt install nvtop
nvtop
is a lightweight task viewer for AMD, Intel, Nvidia, and Apple GPUs. Some tools like btop
(shown later) include very simple GPU metrics (sometimes...), but nvtop
gives you all the hardware details, like power consumption, fan speed, memory consumption, and a process breakdown.
There are tools like radeontop
and amdgpu_top
for AMD, or nvitop
for Nvidia... but nvtop
is almost universally available, and works on the largest variety of GPUs. It's nice to know one tool for all, and even nicer when it's an apt install
away. Or brew install nvtop
on macOS!
asitop
pip3 install asitop
I try not to get too platform-specific with my tooling, but sometimes when I'm on a Mac, I don't have access to the full gauntlet of process monitoring tools I get on Linux.
Lucky for me, there's asitop
, which is a handy visual tool to monitor CPU, GPU, power, and clock speeds. It even breaks down visuals based on E and P cores!
btop
sudo apt install btop
Now we get to it—the Lamborghini of top
s. Not only does it have full color, mouse support, and a sensible video-game-like menu system (no arcane hidden features here!), it makes you look like you're hacking away on TV set.
The visuals aren't all eye-candy, either. Color schemes and almost infinite settings and layouts mean you can set it up for precisely the metrics you want to monitor, usually with just a few keystrokes.
It's worth spending the time to learn some of btop
's options. btop
is usually the first tool I install when getting a feel for a new computer or SBC. Sometimes the colors can get a bit wacky, especially over SSH sessions, but a quick trip to the menus (o
) and setting Truecolor
to False
fixes that right up.
This is by far the tool I get the most comments about when it appears in one of my YouTube videos. The visuals are not only pretty, but functional.
perf
sudo apt install linux-perf
And after the beauty of btop
, we have to go in the complete opposite direction. perf
isn't a top
at all! Well, then, why is it in the list?
Because usually once you monitor a system with a lightweight tool like btop
or atop
, you need to actually figure out the bottleneck. And perf
has deep kernel integration to pull out performance data you didn't even know existed!
I can't even scratch the surface of what it can do—I'll let the guy who I've learned the like 0.2% of perf
's features from describe it so much better: Brendan Gregg's perf
Examples. He even writes a book on Linux performance monitoring!
And yes, that's the same Brendan Gregg famous for Shouting in the Datacenter.
wavemon
sudo apt install wavemon
Since we're off on a tangent of non-top
monitoring tools, I figured I'd throw an honorable mention out to wavemon
.
Before I discovered this tool, I would use watch -n 1
with nmcli
or iwconfig
... but that was not ideal, and a tool like iwconfig
occupies some weird head space where I can never remember the exact name, because there's also ipconfig
or ifconfig
or ip
or whatever other networking tools that have overloaded those registers in my brain.
But now I can see precisely which direction to orient my external wifi antenna, or find a way to eke out an extra 100 Mbps from an otherwise-stable connection!
That rounds out my list of the top 10 ways to monitor Linux... but as I mentioned in the perf
section, this is barely scratching the surface. Seriously, go read through Brendan Gregg's Linux Performance page if you want to go much, much deeper.
Comments
Great collection of terminal tooling, thank you for covering it.
Have you tried iotop-c instead of iotop? There are some interesting updates in data visualization.
Hi
Thanks for your helpful channel. Can you use the "nmon" tool? This is also often used in the Enterprise report on AIX and Linux (especially often in the IBM Power environment). But it also runs on almost everything.
https://nmon.sourceforge.io/
I use bottom (btm). It unfortunately doesn't appear installable via apt, but it can be installed using homebrew. It has mode that makes it look like htop but otherwise lets me see everything at a glance on one screen including battery stats for my laptop. Network, CPU, and Memory are tracked on line graphs in the default view.
Going OT for topxxx
Requirement to monitor about 14 remote systems. Use gkrellmd/gkrelld-daemon, depending on the distribution. Can fit all monitors on one workspace display and at a glance check all monitored systems for cpu activity, temperatures, disk activity, network activity and memeory use. There are numerous plugins - not in use here though.
Thanks Jeff,
Great overview. I’m certainly gonna try some of them. It’s (for me) a bonus if the monitoring tools have a web-UI for simple headless server monitoring. For that reason I like Glances (https://github.com/nicolargo/glances), not on your list.
Also tiptop is worth a mention, especially for RPi users.
Just like 'average load' on Linux is a great misunderstanding since decades [1] 'CPU utilization' has become the same in the meantime [2]. When users see high CPU utilization they think the bottleneck would be the CPU while over the years more likely it's access to DRAM, especially on platforms like the RPi 5 that combines somewhat beefy CPU cores with laughable single-channel 32-bit memory access.
So when you see your RPi 5 maxing out with '+99% CPU utilization' and think moving to something else with 'same CPU performance' (e.g. anything RK3588[S]) would be useless expecting also '+99% CPU utilization' there in reality due to much faster memory access the same task might there run a lot faster and/or with less 'CPU utilization' :)
So knowing the IPC (instructions per cycle) per process (which is what tiptop displays in a simple format) can help you identify tasks that are memory and not CPU bound.
When running as root atop is also able to display IPC per process but many people are overwhelmed by the wall of text thrown at them :)
[1] Since the blog software considers two links in a comment as spam simply search for 'brendan gregg load average linux'
[2] https://www.brendangregg.com/blog/2017-05-09/cpu-utilization-is-wrong.h…
Heh, sadly the blog comment spam detection is set pretty strict (which catches a lot of ham), mostly because with any lower setting it goes from about 2-4 spam comments getting through per day to about 500+, which is overwhelming :(
No worries! Am able to edit comments :)
But the IPC stuff is maybe something your target audience should know (especially the RPi users)
I'll throw ctop into the mix, its a top utility for container. Useful to see all your container metrics and other details in one view, plus logs and exec
Thanks for the video and the blog post, a great overview of the available tools.
What would be really helpful content that people would go back to often, would be to invert this so that it is organized by problem. For example, If I'm trying to solve X, I start with Tool A or B, if I need to drill down more, then I use Tool C.
I would recommend a search for 'brendan gregg linux performance analysis 60 seconds' ;)
A little different (but super helpful!) is `conntrack`. You can do a ton of stuff with this from filtering on any new connections from you system to monitoring the closing of active connections to even listing what connections are active according to your system.
One of my favorite things is to do is just `sudo conntrack -L -d $HOST_IP` and see what has active inbound connections. You can also flip it so see what servers your host has an active connection with (`sudo conntrack -L -s $HOST_IP`).
An honorable mention is `systemd-cgtop` if you are dealing with any multi-user system/environment and/or container workloads. Might not be super great by itself, but if your host has IOAccounting, MemoryAccounting, and CPUAccounting enabled for all cgroups then you can get some really detailed information.
I had tried btop a while back, but the colours being weird over ssh made me revert to using htop. Thank you for writing how to fix that, it's a gorgious interface!