Essential Linux Performance Tools and How to Use Them
A practical guide covering common Linux performance commands—uptime, dmesg, vmstat, mpstat, pidstat, iostat, free, sar, and top—explaining their output, key columns to monitor, and how to interpret results for system troubleshooting.
This article compiles a set of frequently used Linux performance utilities, originally sourced from Netflix's "Linux Performance Analysis in 60,000 Milliseconds" blog, and adds the author's own explanations.
1. uptime
$ uptimeThe command shows overall system load; the three numbers after load average represent the average number of runnable processes over the last 1, 5, and 15 minutes.
2. dmesg | tail
$ dmesg | tailDisplays the tail of the kernel ring buffer, useful for spotting recent errors such as out‑of‑memory kills or dropped TCP packets.
3. vmstat 1
$ vmstat 1Shows per‑second statistics for processes, memory, swap, I/O, and CPU. The first line is an average since boot; subsequent lines are sampled at the specified interval (1 s here). Important columns include:
r : runnable or waiting processes (CPU saturation if > CPU cores)
free : idle memory
si/so : swap in/out (non‑zero indicates memory pressure)
us, sy, id, wa : user, system, idle, and I/O wait CPU percentages (high wa suggests I/O bottlenecks)
4. mpstat -P ALL 1
$ mpstat -P ALL 1Prints per‑CPU utilization each second, helping to verify whether load is evenly distributed across cores.
5. pidstat 1
$ pidstat 1Shows CPU usage per process, similar to top but without screen clearing. Columns of interest:
%CPU : CPU percentage (values >100% indicate multi‑core usage)
PID and Command : identify offending processes.
6. iostat -xz 1
$ iostat -xz 1Provides extended I/O statistics. Key columns:
r/s, w/s : reads/writes per second
await : average I/O wait time (high values signal saturation)
avgqu-sz : average queue size (values >1 may indicate overload)
%util : device utilization percentage (over 60% often means a bottleneck).
7. free -m
$ free -mShows memory usage. Important fields:
buffers : block device cache
cached : page cache (low values together with low free memory can indicate high I/O pressure).
8. sar -n DEV 1
$ sar -n DEV 1Reports per‑second network statistics. Columns to watch:
IFACE : interface name
rxpck/s, txpck/s : packets received/transmitted per second
rxkB/s, txkB/s : kilobytes received/transmitted per second
await : average I/O wait for network devices.
9. sar -n TCP,ETCP 1
$ sar -n TCP,ETCP 1Shows TCP connection activity. Useful columns:
active/s : locally‑initiated connections per second
passive/s : remotely‑initiated connections per second
retrans/s : TCP retransmissions per second.
10. top
$ topA comprehensive, real‑time view of system load, process list, CPU, memory, and swap usage. Highlights include overall load average, per‑process CPU and memory percentages, and state counts (running, sleeping, zombie, etc.).
Summary
The accompanying diagrams illustrate each command’s primary purpose: vmstat for overall system health, mpstat for CPU distribution, pidstat for per‑process CPU usage, iostat for I/O performance, free for memory status, and sar for network monitoring.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
