Bash

Memory / CPU / Load Quick Check

admin by @admin ADMIN
1d ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
One-liners for the three most-requested system metrics. Use in monitoring scripts or as ad-hoc sanity checks.
Bash
Raw
# Memory (free shows everything)
free -h
free -m | awk 'NR==2 {printf "Mem: %d / %d MB (%.1f%%)\n", $3, $2, $3/$2*100}'

# CPU usage (instantaneous from /proc/stat)
top -bn1 | grep -E "^%Cpu" | awk '{print 100 - $8 "%"}'
# Or via mpstat:
mpstat 1 1 | awk '/Average:/ {print "CPU idle: " $NF "%"}'

# Load averages
uptime
cat /proc/loadavg                  # 0.42 0.55 0.61 1/123 4567

# All-in-one summary suitable for a banner / motd
echo "Mem: $(free -m | awk 'NR==2 {printf "%d/%d MB", $3, $2}')   CPU load: $(awk '{print $1, $2, $3}' /proc/loadavg)"
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.