Operations 16 min read

Master Linux System Monitoring: Essential Commands for CPU, Memory, Network, and I/O

This guide presents a comprehensive collection of Linux commands and techniques for monitoring CPU, memory, network interfaces, I/O performance, processes, and system health, explaining each metric's meaning and offering practical examples to help administrators diagnose and optimize their servers efficiently.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux System Monitoring: Essential Commands for CPU, Memory, Network, and I/O

Below is a curated list of Linux commands and explanations for monitoring various aspects of a server, including CPU, memory, network, I/O, processes, and system status.

1. CPU

cat /proc/cpuinfo
# Physical CPU count
cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
# Cores per CPU
cat /proc/cpuinfo | grep 'core id' | sort | uniq | wc -l
# Logical CPUs
cat /proc/cpuinfo | grep 'processor' | sort | uniq | wc -l
mpstat
mpstat 2 10

2. Memory

cat /proc/meminfo
free -gt
df -hT
du -csh ./*
ipcs   # shared memory / queues / semaphores

Common commands to monitor memory usage:

free
vmstat
top
dstat -m

2.1 free

free -h
              total        used        free      shared   buffers   cached
Mem:          7.7G        6.2G        1.5G        17M       33M      184M
-/+ buffers/cache:   6.0G        1.7G
Swap:         24G        581M        23G

Explanation of columns: total: total physical memory. used: memory in use (includes cached memory). free: unused memory. shared: shared memory size. buffers: memory used by buffer cache. cached: memory used by page cache.

The second line ( -/+ buffers/cache) shows the memory actually used by applications (used – buffers – cached) and the memory that could be reclaimed (free + buffers + cached).

2.2 vmstat

Virtual memory statistics provide an overview of processes, memory, swap, I/O, and CPU usage.

vmstat -SM 1 100   # interval 1s, 100 samples, values in MB

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0     0    470    188   1154    0    0     0     4    0    0 99  0  0
 ... (additional rows omitted for brevity)

Key columns: r: runnable processes (waiting for CPU). b: processes blocked for I/O or swap. swpd: memory swapped out. free: idle physical memory. buff: buffer cache (disk block cache). cache: page cache (file data cache). si / so: swap in/out rates. bi / bo: block I/O (KB/s). us / sy / id / wa: CPU user, system, idle, and I/O wait percentages.

3. Network

3.1 Interfaces

ifconfig
iftop
ethtool

3.2 Ports

# TCP ports
netstat -ntlp
# UDP ports
netstat -nulp
# UNIX sockets
netstat -nxlp
# All connections
netstat -nalp
lsof -p <PID> -P
lsof -i :5900
sar -n DEV 1
ss
ss -s

3.3 tcpdump

sudo tcpdump -i any udp port 20112 and ip[0x1f:02]=0x4e91 -XNnvvv
sudo tcpdump -i any -XNnvvv

3.4 nethogs

Monitor per‑process network traffic:

nethogs

4. I/O Performance

iotop
iostat -kx 2
vmstat -SM
vmstat 2 10
dstat --top-io --top-bio

5. Processes

top
htop
ps auxf
ps -eLf   # show threads
ls /proc/<PID>/task

5.1 top

Common interactive commands (press h for help): 1: show each CPU. c: display full command line. H: toggle thread view. P: sort by CPU usage. M: sort by memory usage. R: reverse sort order. u: filter by user. k / r: kill or renice a process.

6. Performance Testing

stress --cpu 8 \
       --io 4  \
       --vm 2  \
       --vm-bytes 128M \
       --timeout 60s

7. Users

w
whoami

8. System Status

uptime
htop
vmstat
mpstat
dstat

9. Hardware Devices

lspci
lscpu
lsblk
lshw -c display
dmidecode

10. Filesystems

# Mount management
mount
umount
cat /etc/fstab
# LVM
pvdisplay
pvs
lvdisplay
lvs
vgdisplay
vgs
df -hT
lsof

11. Kernel & Interrupts

cat /proc/modules
sysctl -a | grep ...
cat /proc/interrupts

12. Logs

dmesg
less /var/log/messages
less /var/log/secure
less /var/log/auth

13. Cron Jobs

crontab -l
crontab -l -u nobody
sudo find /var/spool/cron/ | sudo xargs cat

14. Debugging Tools

14.1 perf

14.2 strace

Print system calls and signals:

strace -p <PID>
strace -p 5191 -f
strace -e trace=signal -p 5191
strace -e trace=open
strace -e trace=file

14.3 ltrace

Print library calls:

ltrace -p <PID>
ltrace -S   # show syscalls

15. Scenario Examples

Scenario 1 – After logging into a server

w        # current users and processes
last      # recent logins and reboots
uptime    # load average
history   # command history

Scenario 2 – Information in /proc

cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/uptime
cat /proc/version
...

Scenario 3 – Run a command in background

nohup <command> >some.log 2>&1 &

Additional Useful Commands

# General monitoring
top
htop
glances
dstat & sar
mpstat
# Performance analysis
perf
# Process handling
ps
pstree -p
pgrep
pkill
pidof
# Network utilities
ip
ifconfig
dig
ping
traceroute
iftop
nload
netstat
vnstat
scp
# Disk I/O
iotop
iostat
# Virtual machines
virt-top
# Permissions
chown
chmod
# Service management
systemctl list-unit-files
# Search
find
locate
# Timing
time
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.

networkLinuxCPUMemorysystem-monitoring
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

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.