Home Knowledge base Skyline Cloud How to Monitor a Linux Server with top, htop, and Key Metrics KNOWLEDGE BASE

How to Monitor a Linux Server with top, htop, and Key Metrics

A practical, command-by-command guide to monitoring a Linux server in real time with top and htop, plus how to read load average, CPU, memory, swap, disk I/O, and network metrics on Ubuntu 22.04/24.04.

Introduction

When a website slows down or an application starts timing out, the first question is always the same: what is the server actually doing right now? On Linux, you don't need a heavy monitoring stack to answer that. Two built-in (or one-command-away) tools — top and htop — plus a handful of metrics commands give you a clear, real-time picture of CPU, memory, disk, and network behaviour.

This tutorial shows you exactly how to read those metrics on Ubuntu 22.04 or 24.04 LTS, the same OS images you get on a Skyline Cloud VPS or cloud server. Every command below has been verified on a live Ubuntu host.

Prerequisites

  • A Linux server running Ubuntu 22.04/24.04 (or a similar distribution).
  • SSH access with a user that can run sudo.

Step 1 — Read the system at a glance with top

top ships with every Linux distribution, so start there. Run it:

top

The header is the most useful part:

top - 21:50:56 up 72 days, 20:54,  3 users,  load average: 1.67, 1.18, 0.76
Tasks:  20 total,   1 running,  19 sleeping,   0 stopped,   0 zombie
%Cpu(s): 29.0 us,  6.5 sy,  0.0 ni, 62.9 id,  0.0 wa,  0.0 hi,  1.6 si,  0.0 st
MiB Mem :   7937.4 total,    402.8 free,   5393.0 used,   2141.6 buff/cache
MiB Swap:    969.0 total,      7.7 free,    961.3 used.   2107.8 avail Mem

What each line tells you:

  • load average — three numbers for the last 1, 5, and 15 minutes. Compare them against your CPU count (run nproc). On a 4-core server, a load of 4.0 means fully busy; sustained values well above your core count mean the system is overloaded.
  • %Cpu(s) — the breakdown of CPU time. The fields that matter most: us (user processes), sy (kernel/system), id (idle), and wa (waiting on disk I/O). High wa points to a slow disk, not a slow CPU. st (steal) above 0 on a VPS means a noisy neighbour is taking your CPU cycles.
  • Mem / Swap — total, free, used, and buff/cache. The number to watch is avail Mem, not free: Linux deliberately uses spare RAM for caches, so low "free" is normal and healthy.

Useful keys while top is running: press M to sort by memory, P to sort by CPU, 1 to show each core separately, k to kill a process by PID, and q to quit.

Step 2 — Install and use htop for a friendlier view

htop is an interactive, colour-coded process viewer that is far easier to read than top. Install it:

sudo apt update
sudo apt install -y htop

Then run:

htop

At the top you get per-core CPU bars, a memory bar, and a swap bar. The colours encode usage type — for the CPU bars, blue is low-priority, green is user, and red is kernel/system time. Below that is a scrollable process list.

Key advantages over top:

  • Scroll with the arrow keys; no need to fit everything on one screen.
  • Press F6 to change the sort column, or F4 to filter by a process name.
  • Press F5 for a tree view that shows parent/child process relationships.
  • Press F9 to send a signal (kill) to the highlighted process — no need to type a PID.

For a longer-lived check, htop is usually the tool you keep open in one SSH window while you reproduce a problem.

Step 3 — Check memory and swap precisely with free

top shows memory live; free gives you a clean snapshot:

free -h
               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       5.3Gi       417Mi       129Mi       2.1Gi       2.1Gi
Swap:          968Mi       961Mi       7.0Mi

Read the available column to judge real memory pressure — it estimates how much RAM is reclaimable for new programs without swapping. If available is near zero and swap is heavily used, the server is memory-constrained and you should size up or investigate a leak. Light swap use by itself is not an alarm.

Step 4 — Understand load and the run queue with uptime and vmstat

For a one-line load reading without opening top:

uptime

To see what's driving the load over time, vmstat samples the system at an interval (here, every 1 second, 5 times):

vmstat 1 5
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 984328 412820 232880 1960148    0    1   389    74    0    1 11  2 86  0  1

The two leftmost columns are key: r is the number of processes waiting for CPU, and b is the number blocked on I/O. If r consistently exceeds your core count, you are CPU-bound; a persistently high b means disk or network I/O is the bottleneck. The si/so columns show swap-in/swap-out — anything above 0 here is active swapping, which hurts performance.

Step 5 — Watch disk I/O with iostat

iostat is part of the sysstat package:

sudo apt install -y sysstat
iostat -xz 2 3

This reports extended per-device stats every 2 seconds, three times. Focus on:

  • %util — how busy the device is; values near 100% mean the disk is saturated.
  • await — average time (ms) per I/O request, including queue time. Rising await signals a struggling disk.
  • r/s and w/s — reads and writes per second.

If you ever saw high wa in top, this is where you confirm the disk is the cause.

Step 6 — Inspect network connections with ss

ss is the modern replacement for netstat. For a quick socket summary:

ss -s

To list listening TCP ports and the process behind each:

sudo ss -tlnp

A sudden spike in established connections to one port — alongside high CPU in htop — often points to a traffic surge or an abusive client.

Quick metric reference

Metric Command Healthy sign Warning sign
Load average uptime, top At or below core count Sustained above core count
CPU top, htop High id, low wa/st High wa (disk) or st (VPS contention)
Memory free -h available comfortable available ~0 + heavy swap
Run queue vmstat 1 5 Low r and b High r (CPU) or b (I/O)
Disk I/O iostat -xz 2 3 Low %util, low await %util near 100%, rising await
Network ss -s, ss -tlnp Stable connection counts Sudden connection spikes

Conclusion

With top, htop, free, vmstat, iostat, and ss, you can diagnose almost any "the server feels slow" report without installing a full monitoring platform. Start with htop for the live picture, confirm memory with free -h, and drill into disk with iostat when you see high I/O wait.

These tools shine on a properly provisioned server. On a Skyline Cloud VPS or cloud server, you get Ubuntu 22.04/24.04 LTS images, in-Kingdom data residency aligned with PDPL, NCA, and SDAIA requirements, and local Arabic-speaking support. Explore the full cloud hosting in Saudi Arabia lineup, and if you run mail on the same infrastructure, see our business email hosting.

Ready to put these monitoring skills to work on infrastructure that stays in the Kingdom? Create your Skyline Cloud account and spin up a server in minutes.

SKYLINE Engineering

@skyline

The engineering team at SKYLINE Industrial Solutions. We publish field-tested guides drawn from real KSA and GCC deployments.

See author profile
SKYLINE engineering services

Need this implemented for you?

Reading is free — building it right takes a team. SKYLINE engineers ship Skyline Cloud for Aramco vendors, banks, hospitals and government agencies across Saudi Arabia. Talk to us before you start.

Aramco Approved Contractor ISO 9001 · ISO 27001 SAMA CSF aligned NCA ECC ready 247+ KSA clients

Comments

0 total · 0 threads
Be the first to leave a comment.