Check Memory Usage Linux: RAM, CPU and Server Load
To check memory usage Linux gives you free -h; read the available column, not free. Add uptime for load average and htop for a live, sortable list of processes. If available is near zero or load average sits above your core count, the server is overloaded and the next step is finding the process behind it.
Here is a one-minute check routine, how to read each number, and what to do next. Commands are for Ubuntu 24.04 LTS and Debian 12; column meanings follow man free.
Contents: Quick check: four commands · Check memory usage Linux-wide with free -h · htop and top: CPU and memory by process · Load average, iowait and steal on a VPS · Find OOM killer events · What to do when the server is overloaded · FAQ
Quick check: four commands
uptime # load average over 1, 5 and 15 minutes
nproc # number of CPU cores
free -h # RAM and swap in human-readable units
df -h / # disk usage on the root filesystem
- Load average like
0.45, 0.60, 0.52: compare withnproc. It's the average number of processes running, waiting for the CPU, or waiting on disk (man uptime). On 1 vCPU, 1.0 means the CPU is fully busy. High load with an idle CPU points at disk, not CPU (see the iowait section). - Memory: the
availablecolumn infree -h. - Disk: a 100% full disk also causes crashes and slowdowns. See how to check and free disk space on Linux.
Check memory usage Linux-wide with free -h
total used free shared buff/cache available
Mem: 1.9Gi 1.1Gi 120Mi 12Mi 780Mi 690Mi
Swap: 1.0Gi 64Mi 960Mi
free(120 MiB) looks scary but is normal. Linux fills idle RAM with file cache (buff/cache) and hands it back on demand.available(690 MiB) is what new processes can actually get without swapping. This is the number to watch.Swap usedthat keeps climbing means you're short on RAM and the system is paging to disk.
Refresh every 2 seconds with free -h -s 2. For raw numbers, cat /proc/meminfo.
htop and top: CPU and memory by process
sudo apt install htop # if it's not installed
htop
Useful keys:
Shift+Psort by CPU,Shift+Msort by memoryF6pick a sort column (for exampleMEM%),F4filter by name,F5tree viewF9kill a process,qquit
The built-in top works the same way: Shift+P, Shift+M, and 1 to show each core.
One-liners you can paste into a chat or hand to an agent:
ps aux --sort=-%mem | head -n 10 # top 10 by memory
ps aux --sort=-%cpu | head -n 10 # top 10 by CPU
docker stats --no-stream # per-container usage, if you run Docker
Load average, iowait and steal on a VPS
The %Cpu(s) line in top breaks CPU time down:
| Field | Meaning | What it points to |
|---|---|---|
us, sy |
user and kernel time | your apps doing work |
wa (iowait) |
CPU waiting on disk | heavy writes, swapping, unindexed queries |
st (steal) |
time the hypervisor gave to other VMs | if it stays noticeably high, show it to support |
id |
idle | headroom |
vmstat 1 5 prints five one-second samples. Non-zero si/so columns mean active swapping.
High load, idle CPU: find the disk hog
If wa stays well above zero, find the process doing the most reads and writes. Both tools come from the sysstat package:
sudo apt install -y sysstat
pidstat -d 1 5 # per-process reads and writes, 5 one-second samples
iostat -xz 1 3 # per-disk load: watch the %util column
Usual suspects: active swapping (so the real problem is memory), a database without indexes, or a backup or rsync running at peak hours.
Find OOM killer events
When RAM runs out completely, the kernel kills the most expensive process. Your bot or database just disappears, and its own log says nothing. The kernel log does:
sudo journalctl -k | grep -i "out of memory"
# Out of memory: Killed process 1234 (python3) ...
sudo journalctl -k -b -1 | grep -i "out of memory" # previous boot
journalctl -k only covers the current boot, so after a reboot check the previous one with -b -1.
What to do when the server is overloaded
- Find the culprit with
ps aux --sortor htop. Usual suspects: a stuck script, a memory leak, a build (npm install,docker build). - Restart or cap it. For a systemd service, set
MemoryMax=in the unit file. - Add swap so short spikes don't trigger the OOM killer: add swap on Ubuntu. Swap is a safety net, not extra RAM.
- Size up if the load is constant. For realistic numbers per workload, read how much RAM a bot needs. 0x.cloud plans run from s1-1 (1 vCPU, 1 GB) to s4-8 (4 vCPU, 8 GB), all on the pricing page; on hourly billing a day of testing an s2-4 ($15.99/month) costs about $2.63, and when you delete the old server its unused balance returns to your account. Setup is $0.
- Add monitoring so you see trends instead of catching spikes by hand: Grafana and Prometheus on Ubuntu.
Let an agent run the check:
Connect to my server (over SSH or through the 0x.cloud MCP) and check its load: uptime, nproc, free -h, df -h, the top 10 processes by memory and by CPU, and kernel OOM events from the last 24 hours. Explain in plain words what is overloaded and what to do. Don't kill or restart anything without asking me.
FAQ
What is the best command to check memory usage on Linux? free -h. Read the available column: it estimates how much memory new programs can use without swapping. The free column looks low on healthy systems because Linux uses spare RAM for cache.
How do I check memory usage by process? Run ps aux --sort=-%mem | head -n 10, or open htop and press Shift+M to sort by memory. For Docker containers use docker stats --no-stream.
What is a normal load average? Compare it with your core count from nproc. On a 2 vCPU server, a load of 2.0 means fully busy; a value that stays above 2 means processes are waiting in line. High load with an idle CPU means processes are waiting on disk.
How do I know if the OOM killer stopped my app? Run sudo journalctl -k | grep -i 'out of memory' (add -b -1 to search the previous boot). The line names the killed process and its PID.
How do I test a bigger plan without overpaying? Use hourly billing and run your real workload: an s2-4 is about $0.109520 per hour, an s1-2 about $0.054725. Hourly never costs more than the monthly price. 0x.cloud servers are in Warsaw.