15 Linux Commands to Check CPU, RAM, and Disk Usage
A slow Linux server or desktop doesnโt always need expensive hardware upgrades. More often than not, a runaway background process, an exhausted memory buffer, or a saturated disk I/O queue is starving your system.
These 15 essential Linux commands will help you diagnose bottlenecks across your processor, system memory, swap partitions, and physical storage within seconds.
When a machine suddenly becomes unresponsive, run these 3 commands first: top (check CPU spikes), free -h (verify available memory), and df -h (check full disk partitions).
๐ฅ Part 1: Best Linux Commands to Check CPU Usage
1. lscpu – Hardware Architecture Summary
Displays CPU model, core counts, thread topology, virtualization flags, and L1/L2/L3 cache allocations.
lscpu
2. top – Real-Time Process Monitor
The universal built-in task manager. Press P to sort by CPU usage, M to sort by memory, or q to quit.
top
3. htop – Enhanced Interactive Terminal GUI
A color-coded visual process viewer allowing easy vertical/horizontal scrolling and direct mouse clicking to kill rogue PIDs.
htop
4. mpstat – Multi-Core CPU Utilization
Breaks down utilization per core in real-time. Ideal for diagnosing single-threaded bottlenecks.
mpstat -P ALL 1
5. uptime – System Load Averages
Shows system uptime along with 1, 5, and 15-minute load averages representing queued tasks.
uptime
๐ง Part 2: Commands to Inspect RAM and Swap Usage
6. free -h – Human-Readable Memory Statistics
The fastest way to view total, used, and available RAM. Always inspect the available column rather than “free”, as Linux aggressively utilizes idle memory for buffer caches.
free -h
7. vmstat – Virtual Memory & I/O Subsystems
Outputs real-time kernel memory, swap paging (si/so), and interrupt metrics at 1-second intervals.
vmstat 1 5
8. cat /proc/meminfo – Raw Kernel Memory Data
Detailed breakdown of dirty memory pages, slab caches, writeback buffers, and active/inactive RAM pools.
cat /proc/meminfo
9. ps – Top Memory-Consuming Processes
Quickly sorts and filters the top 10 processes consuming the most system RAM.
ps aux --sort=-%mem | head -n 11
10. swapon --show – Active Swap Partitions
Exposes active swapfiles, sizes, and utilization percentages to detect disk thrashing.
swapon --show
๐พ Part 3: Commands to Check Disk Space and I/O Activity
11. df -h – Filesystem Disk Usage
Reports available and used capacity across all mounted storage partitions in gigabytes and terabytes.
df -h
12. du -sh – Directory Size Calculation
Calculates the exact disk footprint of a target directory. Use the snippet below for a clean breakdown of your home folder:
du -sh ~/* 2>/dev/null | sort -hr
13. lsblk -f – Block Device Tree
Maps filesystem types, partition UUIDs, labels, and mount points across physical drives.
lsblk -f
14. iostat – Disk I/O Wait & Throughput
Monitors read/write speeds (KB/s), average wait times, and %util saturation metrics on NVMe/SATA drives.
iostat -xz 1
15. ncdu – Interactive NCurses Disk Browser
Fast visual directory scanner that lets you navigate through storage hogs and delete unneeded logs interactively.
ncdu ~
๐ฏ Summary Table: When to Use Which Command
| Diagnostic Target | Primary Command | Deep-Dive Tool |
|---|---|---|
| CPU Spikes & Load | top or uptime |
mpstat -P ALL 1 |
| RAM & Memory Leaks | free -h |
ps aux --sort=-%mem / vmstat 1 |
| Full Disk Space | df -h |
ncdu / du -sh * |
| Slow Disk I/O Bottleneck | vmstat 1 (check wa) |
iostat -xz 1 (check %util) |