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.
top command
topis a real‑time system performance monitoring tool that provides information about processes, including CPU, memory, and swap usage.
# Example: display real‑time system performance
topPress q to exit.
htop command
htopis 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
htopvmstat command
vmstatreports virtual memory statistics, covering processes, memory, swap, and I/O.
# Example: show system resource usage every second, five times
vmstat 1 5iostat command
iostatreports I/O statistics for devices and CPU usage.
# Example: display disk and CPU statistics every second, five times
iostat -d 1 5sar command
sarcollects, 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 5free command
freedisplays memory usage, including physical memory and swap.
# Example: show memory usage in megabytes
free -mnetstat command
netstatshows network connections, routing tables, and interface statistics.
# Example: display all network connections
netstat -aniftop command
iftopmonitors network traffic in real time, presenting a graphical view of current connections.
# Example: install and run iftop
sudo apt install iftop # if not installed
iftoptcpdump command
tcpdumpis 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 eth0pidstat command
pidstatreports 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 5nload command
nloadmonitors network traffic in real time, showing bandwidth usage graphically.
# Example: install and run nload
sudo apt install nload # if not installed
nloadGlances tool
Glancesis 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
glancesMonitoring system logs
System logs are essential for understanding system health and troubleshooting issues.
# Example: view the system log
cat /var/log/syslogCustom 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
doneConclusion
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.
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.
