DEV Community

Omor Faruk
Omor Faruk

Posted on

Linux System Monitoring from the Command Line


System monitoring is an essential part of Linux server administration and DevOps. Before deploying a production application, it is important to understand how the server is performing and whether CPU, memory, disk, network, or individual processes are causing problems.

You don't always need a web dashboard such as Grafana to monitor a Linux server. There are several powerful command-line monitoring tools that provide real-time information directly inside your terminal.

1. btop — Beautiful and Easy

btop is one of the easiest terminal-based system monitoring tools.

It provides a graphical-style interface directly in the terminal and allows you to monitor:

  • CPU usage
  • Memory usage
  • Swap
  • Disk activity
  • Network activity
  • Running processes
  • CPU cores
  • System load

Installation

sudo apt update
sudo apt install btop
Enter fullscreen mode Exit fullscreen mode

Start btop

btop
Enter fullscreen mode Exit fullscreen mode

You will get a live dashboard directly inside your terminal.

Why use btop?

btop
 ├── CPU
 ├── Memory
 ├── Swap
 ├── Disk
 ├── Network
 └── Processes
Enter fullscreen mode Exit fullscreen mode

It is an excellent choice when you want something simple, fast, and visually attractive.


2. Glances — Complete System Overview

Glances is designed to show a large amount of system information on a single screen.

It can monitor:

  • CPU
  • RAM
  • Swap
  • Disk usage
  • Disk I/O
  • Network traffic
  • Processes
  • Load average
  • System uptime
  • Docker containers
  • Sensors

Installation

sudo apt update
sudo apt install glances
Enter fullscreen mode Exit fullscreen mode

Start Glances

glances
Enter fullscreen mode Exit fullscreen mode

Glances is particularly useful when you want to quickly answer:

"What is happening on this server right now?"

For example, you can quickly identify whether the server is experiencing high CPU usage, memory pressure, disk activity, or unusual processes.


3. bottom (btm) — Powerful Terminal Graphs

bottom, commonly launched using the btm command, is another powerful terminal monitoring tool.

It provides interactive graphs for system resources and processes.

Installation

Depending on your Linux distribution, you can install it through the available package manager.

For example:

sudo apt install bottom
Enter fullscreen mode Exit fullscreen mode

Then run:

btm
Enter fullscreen mode Exit fullscreen mode

It is a good alternative if you prefer a more graph-oriented terminal interface.


4. nmon — Lightweight Monitoring

nmon is a lightweight monitoring tool that has been popular among Linux administrators for many years.

It can monitor:

  • CPU
  • Memory
  • Disk
  • Network
  • Processes
  • Filesystems
  • System load

Installation

sudo apt update
sudo apt install nmon
Enter fullscreen mode Exit fullscreen mode

Start

nmon
Enter fullscreen mode Exit fullscreen mode

nmon is particularly useful on servers where you want a lightweight monitoring solution with minimal overhead.


5. htop — Process Monitoring

htop is one of the most popular Linux process-monitoring tools.

Install it with:

sudo apt install htop
Enter fullscreen mode Exit fullscreen mode

Then:

htop
Enter fullscreen mode Exit fullscreen mode

Unlike btop and Glances, htop is primarily focused on process management.

You can see:

  • Running processes
  • CPU usage
  • Memory usage
  • Process IDs
  • Users
  • Process priority
  • Process tree

You can also search, sort, and kill processes directly from the interface.


Comparison

Tool Rating Best For
btop ⭐⭐⭐⭐⭐ Beautiful and easy terminal monitoring
Glances ⭐⭐⭐⭐⭐ Monitoring many metrics in one screen
bottom (btm) ⭐⭐⭐⭐⭐ Powerful terminal graphs
nmon ⭐⭐⭐⭐ Lightweight system monitoring
htop ⭐⭐⭐ Mainly process monitoring

Which One Should You Use?

There isn't one tool that is best for every situation.

For beginners

Use:

btop
Enter fullscreen mode Exit fullscreen mode

It is easy to understand and provides a very good visual overview.

For DevOps and server administration

Use:

glances
Enter fullscreen mode Exit fullscreen mode

It provides a broader overview of the server and is useful when troubleshooting resource problems.

For detailed terminal graphs

Use:

btm
Enter fullscreen mode Exit fullscreen mode

For process management

Use:

htop
Enter fullscreen mode Exit fullscreen mode

For lightweight monitoring

Use:

nmon
Enter fullscreen mode Exit fullscreen mode

Useful Linux Monitoring Commands

You don't always need a monitoring application. Linux already provides many useful commands.

CPU

top
Enter fullscreen mode Exit fullscreen mode

or:

lscpu
Enter fullscreen mode Exit fullscreen mode

Memory

free -h
Enter fullscreen mode Exit fullscreen mode

Disk space

df -h
Enter fullscreen mode Exit fullscreen mode

Disk usage

du -sh *
Enter fullscreen mode Exit fullscreen mode

Network interfaces

ip -br a
Enter fullscreen mode Exit fullscreen mode

Running processes

ps aux
Enter fullscreen mode Exit fullscreen mode

System load and uptime

uptime
Enter fullscreen mode Exit fullscreen mode

Open network connections

ss -tulpn
Enter fullscreen mode Exit fullscreen mode

A Practical DevOps Workflow

When troubleshooting a Linux server, I usually recommend starting with:

btop
Enter fullscreen mode Exit fullscreen mode

If something looks abnormal, investigate further:

free -h
df -h
uptime
ps aux
ss -tulpn
Enter fullscreen mode Exit fullscreen mode

For example, if btop shows that RAM usage is very high, run:

free -h
Enter fullscreen mode Exit fullscreen mode

Then identify which processes are consuming memory:

ps aux --sort=-%mem | head
Enter fullscreen mode Exit fullscreen mode

If CPU usage is high:

ps aux --sort=-%cpu | head
Enter fullscreen mode Exit fullscreen mode

For disk space:

df -h
Enter fullscreen mode Exit fullscreen mode

This combination gives you a simple but powerful troubleshooting workflow.


Final Recommendation

For a modern Linux/DevOps environment, I would keep these three tools installed:

sudo apt install btop glances htop
Enter fullscreen mode Exit fullscreen mode

Then use them according to the situation:

btop       → Daily system monitoring
Glances    → Complete server overview
htop       → Process investigation
Enter fullscreen mode Exit fullscreen mode

For a single Linux server, these tools are often enough for quick real-time troubleshooting directly from the terminal.

For monitoring many production servers over time, however, you should move to a proper observability stack such as Prometheus + Grafana + Loki, where you can collect historical metrics, logs, dashboards, and alerts.

Top comments (2)

Collapse
 
ywnigcsmku2m profile image
ywnigcsmku2m •

htop là bạn thân, nhưng production thường cài btop (gốc C++, nhẹ hơn, UI đẹp hơn) hoặc glances khi cần overview cross-platform. Với container, ctop hoặc dockerc (TUI) cho xem resource per-container mà không cần docker stats lặp lại.

Logging side: journalctl -f -u <service> kết hợp grep --line-buffered để filter real-time thay vì tail file log thủ công. Network: nethogs (per-process bandwidth) hay iftop (per-connection) vẫn勝过 netstat/ss khi debug spike đột ngột.

Disk I/O bottleneck hay bị bỏ qua — iostat -xz 1 hoặc iotop -o (chỉ show process đang I/O) tiết kiệm thời gian tìm process "ăn" disk. CPU: perf top cho sampling profile không cần recompile, hữu ích khi process 100% CPU nhưng không rõ function nào.

Alerting nhỏ: watch -n 5 'sensors | grep -E \"Core|Package\"' theo dõi thermal throttling trên bare metal. Trên cloud thì cloud-init + telegraf sidecar đẩy metric ra Prometheus/Grafana mới scale được.

Một thói quen: luôn có tmux/screen session chạy htop + journalctl -f side-by-side khi deploy — phát hiện OOM kill hoặc CPU spike ngay lúc rollout PS: the tool I meant is on labagent .tech

Collapse
 
dev2023-op profile image
Owen Ross •

this is a useful post, thankyou