Home/Engineer/OS / Systems/Linux System Resource Monito…
OS / SystemsIntermediateubuntucentosdebianlinuxmonitoringcpu

Linux System Resource Monitoring

A practical roundup of commands and tools for real-time CPU, memory, disk, and network monitoring, and for finding bottlenecks.

Contents
  1. CPU Monitoring
  2. Memory Monitoring
  3. Disk Monitoring
  4. Network Monitoring
  5. vmstat / sar
  6. CPU Alert Script

CPU Monitoring

Bash
top -d 1
htop

uptime   # check load average (overload if higher than core count)
nproc
lscpu | grep "CPU(s):"

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

Memory Monitoring

Bash
free -h
watch -n 1 free -h

ps aux --sort=-%mem | head -10
cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable|Cached"
swapon --show

Disk Monitoring

Bash
df -h
df -h /var

du -sh /var/* | sort -rh | head -10
du -sh /*     | sort -rh | head -10

df -i   # inode usage

iostat -xz 1
iotop -ao

Network Monitoring

Bash
ss -tunlp
ss -s

iftop -i eth0
nload eth0

# check connection counts (DDoS detection)
ss -tn | awk 'NR>1 {print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head

vmstat / sar

Bash
vmstat 1 10

sudo apt install sysstat
sar -u 1 5   # CPU
sar -r 1 5   # memory
sar -d 1 5   # disk

CPU Alert Script

Bash
#!/bin/bash
THRESHOLD=90
CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}' | cut -d'%' -f1 | cut -d',' -f1)
CPU=${CPU%.*}

if [[ $CPU -gt $THRESHOLD ]]; then
  echo "[ALERT] CPU ${CPU}%" | mail -s "CPU Alert" admin@example.com
fi
#linux#monitoring#cpu#memory#disk#iostat
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗

Questions & answers

Ask a question about this guide. We'll review and reply.