What Fills the Disk and What Loads the Server
When a disk is full or the server is slow, these commands show the cause. They were tested on Ubuntu 26.04 LTS; run them as root or with sudo.
How Full Are the Disks?
df -h -x tmpfs -x devtmpfs -x squashfs -x overlay
Use% shows how full each drive is, Mounted on where it is in the folder tree. The -x options hide the system's memory drives, which are not real disks. Above 90 % it is time to clean up: a full disk stops databases and many other programs.
Which Folders Are the Largest?
du -xh --max-depth=1 / | sort -h | tail
This lists the largest folders on the system drive, the largest last. Then look into the largest one, for example du -xh --max-depth=1 /var | sort -h | tail, and so on.
Easier to browse is ncdu: install it with apt install ncdu and run ncdu -x /. Move with the arrow keys, open a folder with Enter, and leave with q.
Safe Places to Free Space
apt clean | Deletes downloaded installation packages. |
apt autoremove | Removes packages and old kernels that nothing needs any more. Read the list before you answer y. |
journalctl --disk-usagejournalctl --vacuum-size=500M | Shows the size of the system log, and shrinks it to 500 MB. |
docker system dfdocker image prune -a | If you use Docker: shows its space, and deletes images that no container uses. |
Delete only files you know. Your own data, databases and everything in /etc are not "junk", even when they are large.
What Loads the Server?
uptime
The three numbers after load average are the load of the last 1, 5 and 15 minutes. Compare them with the number of processor threads, which nproc shows: below that number the server keeps up; well above it, work has to wait.
htop
htop is already installed on Ubuntu. It shows every processor thread and the memory at the top, and below them the programs, the busiest first. Press F6 to choose another sort order (for example PERCENT_MEM for memory), F9 to stop the selected program, and q to leave.
Memory: free -h. The column available is what programs can still use; the buff/cache that Linux uses for speed is given back when needed, so a small free number alone is no problem.
Cockpit shows the same information as graphs: Manage Your Linux Server in the Browser With Cockpit.