The “Disk Full” Catastrophe
One of the most common reasons a Linux server crashes is simply running out of hard drive space. When a database like MySQL attempts to write a transaction to the disk and encounters zero free bytes, it completely shuts down to prevent data corruption.
When this happens on a remote headless server, you cannot open a graphical file explorer to see which folders are taking up the most space. You must hunt down the massive files using two fundamental terminal utilities: df (Disk Free) and du (Disk Usage).
1. Auditing Total Free Space (df)
The first step in an outage is determining if the disk is actually full, or if the problem lies elsewhere. You do this with the df command.
df -h
(The -h flag is critical. It stands for “Human Readable”. Without it, Linux will output the free space in raw 1-kilobyte blocks, which is incredibly difficult to read. The -h flag forces it to use Megabytes and Gigabytes).
The output will list every mounted partition on your server. Look for the mount point labeled / (the root of your main hard drive). If the “Use%” column for that drive says 100%, you have found the cause of your server crash.
2. Hunting for Massive Files (du)
Once you confirm the drive is full, you have to find out what is filling it up. Usually, it is a massive, runaway log file hidden deep in the /var/log directory, or a massive database backup.
The du command calculates the exact size of a specific directory and everything inside it.
sudo du -sh /var/log
Breaking down the syntax:
-s: Summarize. Instead of printing the size of every single individual file inside the folder, just print one grand total for the whole folder.-h: Human Readable (Gigabytes)./var/log: The specific folder we are investigating.
If the terminal tells you that /var/log is consuming 40 Gigabytes, you know you are looking in the right place.
3. The Ultimate Forensic Command
Checking folders one by one using du -sh is tedious. If you are desperate to find massive files quickly, you can combine du with the sort and head commands to instantly generate a “Top 10” list of the largest files on your server.
sudo du -ah / | sort -rh | head -n 10
How this pipeline works:
du -ah /: Start at the absolute root of the hard drive (/) and calculate the size of every single file and folder (-afor all).sort -rh: Take that massive output and numerically sort it in Reverse (-r) so the biggest numbers are at the top, respecting Human-readable (-h) suffixes like G for Gigabyte and M for Megabyte.head -n 10: Only print the top 10 lines of the result to the screen.
This command might take a few minutes to run on a massive server, but it will pinpoint the exact runaway file that is crashing your infrastructure.
Conclusion
The combination of df and du is the standard protocol for storage forensics in Linux. By understanding how to check aggregate partition health and how to sort deep-level file usage, administrators can rapidly triage full-disk outages and restore critical services.