Operations 7 min read

Essential Linux Monitoring Tools and How to Use Them

This guide introduces essential Linux monitoring commands such as top, htop, vmstat, iostat, sar, netstat, iftop, tcpdump, and Glances, explains their usage with example code, and shows how to analyze logs and create custom scripts for comprehensive system performance tracking.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Essential Linux Monitoring Tools and How to Use Them

top command

top

is a real‑time system performance monitoring tool that provides information about processes, including CPU, memory, and swap usage.

# Example: display real‑time system performance
 top

Press q to exit.

htop command

htop

is an enhanced version of top offering a more intuitive, interactive interface with color and mouse support.

# Example: install and run htop
 sudo apt install htop  # if not installed
 htop

vmstat command

vmstat

reports virtual memory statistics, covering processes, memory, swap, and I/O.

# Example: show system resource usage every second, five times
 vmstat 1 5

iostat command

iostat

reports I/O statistics for devices and CPU usage.

# Example: display disk and CPU statistics every second, five times
 iostat -d 1 5

sar command

sar

collects, reports, and saves system activity information, showing CPU, memory, and disk usage.

# Example: install sysstat and display resource usage every second, five times
 sudo apt install sysstat  # if not installed
 sar 1 5

free command

free

displays memory usage, including physical memory and swap.

# Example: show memory usage in megabytes
 free -m

netstat command

netstat

shows network connections, routing tables, and interface statistics.

# Example: display all network connections
 netstat -an

iftop command

iftop

monitors network traffic in real time, presenting a graphical view of current connections.

# Example: install and run iftop
 sudo apt install iftop  # if not installed
 iftop

tcpdump command

tcpdump

is a network packet capture tool used to capture and analyze network packets.

# Example: install and capture packets on eth0
 sudo apt install tcpdump  # if not installed
 sudo tcpdump -i eth0

pidstat command

pidstat

reports statistics for processes, including CPU, memory, and I/O usage.

# Example: install sysstat and display process statistics every second, five times
 sudo apt install sysstat  # if not installed
 pidstat 1 5

nload command

nload

monitors network traffic in real time, showing bandwidth usage graphically.

# Example: install and run nload
 sudo apt install nload  # if not installed
 nload

Glances tool

Glances

is an all‑in‑one real‑time system monitoring tool that provides a comprehensive overview of system performance.

# Example: install and run Glances
 sudo apt install glances  # if not installed
 glances

Monitoring system logs

System logs are essential for understanding system health and troubleshooting issues.

# Example: view the system log
 cat /var/log/syslog

Custom script monitoring

Write custom scripts to create tailored monitoring solutions for specific needs.

# Example: Bash script to monitor CPU usage
#!/bin/bash
while true; do
  echo "CPU Usage: $(top -bn1 | grep \"Cpu(s)\" | awk '{print $2 + $4}')%"
  sleep 1
done

Conclusion

Linux monitoring tools are indispensable for system administrators and operations engineers. By mastering commands such as top, htop, vmstat, iostat, nload, and utilities like sar and pidstat, you can obtain real‑time and historical performance data, quickly locate bottlenecks, and take corrective actions. Combining these tools with log analysis and custom scripts enables precise tuning, fault diagnosis, and capacity planning, ensuring Linux systems run efficiently and reliably.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceLinuxsystem-monitoring
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.