The problem
You need to monitor system performance, identify bottlenecks, or troubleshoot slowdowns.
The solution
# Real-time process monitoring
top
htop # Enhanced version (install if needed)
# Monitor CPU usage by process
pidstat 1 # Every 1 second
# I/O monitoring
iotop # Disk I/O by process
iostat -x 1 # Detailed I/O stats every second
# Memory monitoring
vmstat 1 # Virtual memory stats
free -h -s 2 # Memory usage every 2 seconds
# Network monitoring
iftop # Network bandwidth by connection
nethogs # Bandwidth by process
iptraf-ng # Interactive network monitor
# Disk activity
dstat --disk-util # Disk utilization
iostat -d 1 # Disk I/O every second
# Continuous monitoring with watch
watch -n 1 'df -h' # Disk space every second
watch -n 2 'free -h' # Memory every 2 seconds
watch -n 5 'uptime' # Load average every 5 seconds
# Combined monitoring tools
glances # Comprehensive monitoring (install)
nmon # Nigel's performance monitor
# Process tree with resource usage
ps aux --sort=-%mem | head -10 # Top memory processes
ps aux --sort=-%cpu | head -10 # Top CPU processes
# Temperature monitoring
sensors # Hardware sensors
lm-sensors # May need installation
# Monitor specific process
watch -n 1 'ps -p PID -o pid,ppid,pcpu,pmem,cmd'
# Log monitoring in real-time
tail -f /var/log/syslog
multitail /var/log/*.log # Multiple logs simultaneously
# System activity reporter
sar -u 1 3 # CPU usage 3 times at 1s interval
sar -r 1 3 # Memory usage
# Power usage (for laptops)
powertop # Analyze power consumptionPut it to work
# Quick performance check
top
# Press '1' to show all CPUs
# Press 'M' to sort by memory
# Press 'P' to sort by CPU
# Monitor disk I/O during backup
iotop
# Watch which processes are reading/writing
# Check network usage during file transfer
iftop -i eth0
# Continuous memory monitoring
watch -n 2 'free -m | grep "Mem:"'
# Find memory leaks
ps aux --sort=-%mem | head -5Worth knowing
htop provides better interface than top. Install monitoring tools: sudo apt install htop iotop iftop glances. Use Ctrl+C to stop monitoring commands.