Bash System Info Commands - df, du, free, uname, uptime, lsblk
Monitor system resources with bash commands for disk usage (df, du), memory (free), system details (uname), uptime, and block device information (lsblk).
Detailed Explanation
System Information Commands
Monitoring system resources is a core task for system administrators and DevOps engineers. Bash provides several commands for checking disk, memory, CPU, and system details.
Disk Usage with df
df (disk free) shows filesystem-level disk usage:
df -h # human-readable output
df -hT # include filesystem type
df -h / # specific mount point
df -i # inode usage (file count limits)
df -h --total # include total row
Directory Sizes with du
du (disk usage) shows per-directory sizes:
du -sh * # summary of each item in current dir
du -h -d 1 # one level deep
du -sh node_modules/ # single directory total
du -h --max-depth=2 | sort -rh | head -20 # largest directories
Memory with free
free -h # human-readable
free -m # megabytes
free -s 5 # refresh every 5 seconds
System Details with uname
uname -a # all information
uname -r # kernel release
uname -m # architecture (x86_64, arm64)
uname -n # hostname
cat /etc/os-release # distribution details
Uptime and Load
uptime # uptime + load averages
uptime -p # pretty format
uptime -s # boot time
cat /proc/loadavg # load averages + running processes
CPU Information
nproc # number of CPU cores
lscpu # detailed CPU info
cat /proc/cpuinfo | grep "model name" | head -1
Block Devices
lsblk # block device tree
lsblk -f # with filesystem info
fdisk -l # partition details (requires root)
Network Interfaces
ip addr # IP addresses
ip route # routing table
ss -tlnp # listening TCP ports
Monitoring Script
#!/usr/bin/env bash
echo "=== System Report $(date) ==="
echo ""
echo "--- Hostname: $(hostname) ---"
echo "--- Uptime: $(uptime -p) ---"
echo ""
echo "=== Disk Usage ==="
df -h | grep -E "^/dev"
echo ""
echo "=== Memory ==="
free -h
echo ""
echo "=== Top 5 Processes by Memory ==="
ps aux --sort=-%mem | head -6
echo ""
echo "=== Load Average ==="
cat /proc/loadavg
Use Case
System information commands are used daily by system administrators for health monitoring, capacity planning, and troubleshooting. They are commonly incorporated into monitoring scripts, alerting systems, and status dashboards. Understanding disk and memory usage patterns helps prevent outages caused by resource exhaustion.
Try It — Bash Cheat Sheet
Related Topics
Bash Process Management - ps, kill, top, bg, fg, jobs, nohup
Process Management
Bash File Operations - ls, cp, mv, rm, find, chmod
File Operations
Bash Network Commands - curl, wget, ssh, scp, ping, netstat
Network
Bash Script Basics - Shebang, Arguments, Exit Codes, set Options
Script Basics
Bash Pipes and Redirects - |, >, >>, 2>, <, <<
Pipes & Redirects