Running disk space and RAM usage
df answers “how full are the filesystems?” du answers “which folder is fat?” free answers “how much RAM and swap are used?” Together they tell you whether the dedicated server is healthy.
Disk space right now
df -hdf -hTdf -h / /boot /varRead Use%. Above about 80% on / or /var, start cleaning or expanding LVM. 100% can stop apt, logs, and databases.
df -iNote
A disk can be “full” because it ran out of inodes (millions of tiny files) while
df -h still shows free bytes. Mail queues and session folders do this.What is using the space
du -h --max-depth=1 / 2>/dev/null | sort -hdu -sh /var/* /home/* /root 2>/dev/nulldu -sh /var/log /var/lib /var/cachefind /var -xdev -type f -printf '%s %p' 2>/dev/null | sort -n | tailncdu is a nicer interactive view:
apt install -y ncduncdu /RAM and swap
free -hfree -mwatch -n 1 free -h| Column | Meaning |
|---|---|
| total | Physical RAM the OS sees |
| used | In use (includes cache depending on view) |
| available | What new programs can still get — trust this more than “free” |
| buff/cache | Linux using spare RAM as disk cache. This is normal. |
| swap | Overflow on disk. Some swap use is OK. Constant heavy swap is slow. |
ps aux --sort=-%mem | headapt install -y htophtopIn htop, F6 sorts. Watch MEM% and CPU%. Press q to quit. top is always there if htop is not installed.
topvmstat 1 5cat /proc/meminfoIs the disk busy?
apt install -y sysstatiostat -xz 1 5iotop -oHigh %util on a disk in iostat means that device is saturated. On RAID1 both members should look similar. If one disk is much slower, check SMART.
Logs filling the disk
journalctl --disk-usagedu -sh /var/logls -lhS /var/log | headjournalctl --vacuum-time=7dImportant note
Do not delete the current log file a process still has open without rotating it. Prefer
journalctl --vacuum-time and logrotate.