When a server feels slow or a game lags, the first job is to see what's using the resources. These commands tell you in seconds whether it's CPU, RAM or disk — and which process is to blame.
Quick answer
On Linux, use top or htop to see CPU and memory per process, free -h for RAM and swap, df -h for free disk space and du -sh * to find what is using it. For disk activity, iostat or iotop show which process is reading or writing.
CPU & memory in real time: top / htop
top is on every server; htop is the friendlier colour version (install it if you can). Both show a live list of processes sorted by CPU, so you can spot the hog:
top # press 'M' to sort by memory, 'P' by CPU, 'q' to quit
htop # nicer UI; arrow keys + F9 to kill a processMemory at a glance: free
free -h shows total, used and available RAM in human-readable units:
free -h
# total used free available
# Mem: 7.7Gi 3.1Gi 1.2Gi 4.3GiLinux uses spare RAM for cache, so "free" looks low on a healthy server. The "available" column is the real figure — that's how much your apps can still use.
Disk space: df & du
df -h shows how full each disk is. If one is at 100%, that alone can crash services:
df -h # usage per filesystem
du -sh /home/* | sort -h # which folders are biggestDisk I/O: is the disk the bottleneck?
High %wa (I/O wait) in top means processes are waiting on the disk — a classic cause of lag on slow storage. iostat (from sysstat) shows per-disk activity.
Quick triage order
htop/top— what's using the CPU?free -h— is RAM exhausted (low "available")?df -h— is a disk full?- High
%wain top — is storage the bottleneck?
Slow server? top, free, df — in that order. Ninety seconds tells you whether it's CPU, RAM or disk.
Checking network usage too (nload / iftop / vnstat)
CPU, RAM and disk aren't the only bottlenecks — a saturated network link causes the same lag symptoms. nload and iftop show live bandwidth per connection; vnstat tracks usage over time so you can spot a recurring spike (a backup job, a DDoS, or a player download surge).
Finding what's eating disk space long-term
du -sh is slow on a big tree. ncdu gives an interactive, much faster breakdown of what's filling a disk — logs, old backups and world/save files are the usual suspects on a game server. For a longer-term view of memory and CPU, vmstat 2 prints a fresh snapshot every 2 seconds so you can watch trends instead of one instant.
How to prevent resource exhaustion on a game or web server
- Set up log rotation so logs don't silently fill the disk over weeks.
- Monitor with a lightweight always-on tool (Netdata, Munin) instead of only checking manually when something feels wrong.
- Set per-service memory limits (systemd
MemoryMax) so one runaway process can't take down everything else. - Schedule backups and heavy jobs off-peak so they don't spike CPU/disk I/O during play hours.
- Keep at least 10–15% of each disk free — many services misbehave badly once a disk hits 100%.
Related Linux performance guides
If RAM usage keeps climbing until a process gets killed, see Linux out of memory (OOM killer). If a disk actually fills up, read "No space left on device". To work out whether game lag is CPU or network specifically, see game server lag: CPU or network?, and for more day-to-day commands see our essential Linux commands for game server admins.