How to Monitor Real-Time System Resources with htop and top

htop and top provide real-time visibility into CPU, memory, and process activity — the first tools to reach for when diagnosing a server that feels slow or unresponsive.

top: The Built-In Standard

top

Shows a live-updating view of CPU/memory usage and running processes, sorted by CPU usage by default — available on virtually every Linux system with no installation needed.

Key top Interactive Commands

P   # sort by CPU usage
M   # sort by memory usage
k   # kill a process (prompts for PID)
q   # quit

htop: A More User-Friendly Alternative

sudo apt install htop -y
htop

Adds color-coded output, mouse support, and easier process searching/killing compared to top's more austere interface.

Understanding the Key Metrics

MetricMeaning
Load averageAverage system load over 1/5/15 minutes; compare against your CPU core count
%CPUPercentage of a single CPU core a process is using
RES (Resident Memory)Actual physical RAM a process is currently using
VIRT (Virtual Memory)Total virtual memory a process has mapped, often much higher than actual usage

Interpreting Load Average

A load average roughly equal to your CPU core count indicates full utilization; significantly higher indicates processes are waiting for CPU time — e.g. a load average of 8 on a 4-core server suggests the system is meaningfully oversubscribed.

Filtering/Searching for a Specific Process in htop

F4   # filter by process name

Killing a Runaway Process

# In htop: select the process, press F9, choose signal (15 for graceful, 9 for force)
# Or from the command line:
kill -15 PID
kill -9 PID   # force kill if graceful termination doesn't work

Always try a graceful termination (-15) first, reserving force kill (-9) for processes that don't respond to the graceful signal.

Viewing Per-Core CPU Usage in htop

htop's header displays individual core utilization bars — useful for spotting whether load is evenly distributed or concentrated on a single core (which can indicate a single-threaded process bottleneck).

Sorting by Memory to Find Memory Leaks

htop
M   # sort by memory usage

A process whose memory usage climbs steadily over time without leveling off is a classic sign of a memory leak worth investigating.

Command-Line Alternative for Scripting: ps

ps aux --sort=-%cpu | head -10

Useful when you need a one-time snapshot for a script or report, rather than htop/top's interactive live view.

Common Errors

High load average but low CPU usage per process — check for processes in "D" state (uninterruptible sleep, often waiting on disk I/O) rather than assuming it's purely a CPU issue.

Continue Reading

Browse more articles in Linux Server Administration.

  • htop tutorial, top command linux, monitor cpu usage, load average explained
  • 0 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

How to Update and Upgrade Your Ubuntu or Debian VPS

Keeping your VPS updated is one of the most important and simplest maintenance tasks — it...

How to Enable and Configure Swap on a Linux VPS (Ubuntu & Debian)

Swap is disk space Linux can use as overflow memory when physical RAM is exhausted. It won't make...

How to Manage Services with systemd and systemctl

systemd is the service manager used by Ubuntu, Debian, and most modern Linux distributions to...

How to Read and Analyze Linux Logs with journalctl

On modern Ubuntu and Debian systems, journalctl is the central tool for viewing system and...

How to Schedule Tasks with Cron on a Linux VPS

Cron is the standard Linux job scheduler, used to automate recurring tasks like backups, log...