The Disk Space Auditing Vector
On an Ubuntu Linux server, disk space can rapidly disappear due to bloated log files, uncompressed backups, or unchecked application caches. Identifying the specific files and directories responsible for consuming gigabytes of storage is critical for maintaining server stability. Instead of blindly deleting files, administrators must precisely isolate the largest data consumers using the command line.
How to Find the Largest Files and Directories
The most efficient method to audit disk usage is to combine the du (disk usage), sort, and head commands to generate a highly readable report.
1. Open your terminal or connect to your server via SSH.
2. To find the top 20 largest files and directories within a specific path (for example, the root directory /), execute the following command:
sudo du -a / | sort -n -r | head -n 20
3. To make the output human-readable (displaying sizes in MB or GB instead of raw blocks), you can use a slightly modified command:
sudo du -ah / | sort -rh | head -n 20
4. The terminal will immediately output a descending list, with the most massive directories and files at the very top.
This allows you to quickly target and investigate the exact sources of disk consumption without manually exploring the file system.