How to Check Disk Space in Ubuntu

The File System Interrogation Vector

When operating a headless Ubuntu server—whether it is hosting a massive PostgreSQL database or functioning as an active CI/CD deployment node—monitoring storage telemetry is mathematically critical. If the `/var/log` directory fills 100% of the solid-state drive with error logs, or if a rogue Docker container consumes all available inodes, the Linux kernel will violently crash, unable to write even a single byte of temporary data to the disk. You must routinely instruct the OS to execute a comprehensive interrogation of the mounted file systems to determine exactly how many gigabytes of mathematical storage remain free.

How to Check Disk Space in Ubuntu

The Linux kernel provides highly specific terminal utilities to extract this data. The `df` (disk free) command analyzes the overall partition structure, while the `du` (disk usage) command calculates the mathematical weight of specific directories.

1. Open your terminal application or connect to the server via SSH.
2. Method 1: The Master Partition Dump (`df`):
* This is the mathematically superior method for analyzing overall system health and partition allocation.
* Type exactly:
df -h
* Press Enter.
* The Parameters: The `-h` flag is critical. It instructs the kernel to format the output in “Human-readable” mathematics (Megabytes and Gigabytes) rather than an incomprehensible string of raw 1K blocks.
* The Diagnostic Dump: The terminal will output a precise grid. Look for the row representing your primary root partition (usually mounted on `/` and named `/dev/sda1` or `/dev/nvme0n1p2`).
* The grid will explicitly detail: Size (Total capacity), Used (Consumed space), Avail (Free space), and Use% (The percentage filled). If `Use%` breaches 90%, you are in mathematical danger.
3. Method 2: The Directory Weight Audit (`du`):
* If `df -h` reveals that your drive is 99% full, you must identify which specific folder is consuming the space (e.g., is it `/var/log` or `/home/ubuntu/downloads`?).
* Navigate to the root directory: cd /
* Type exactly (requires `sudo` to bypass permission blocks):
sudo du -sh * | sort -hr
* Press Enter.
* The Mathematical Result: The OS will violently scan every single file on the drive, calculate the total weight of each top-level directory, and render a list sorted from largest (heaviest) to smallest. (e.g., `45G /var`, `12G /home`).
4. Method 3: The GUI Override (Desktop Ubuntu Only):
* If you are operating a visual Ubuntu Desktop environment.
* Press the Super (Windows) key, type Disk Usage Analyzer, and launch the native GUI utility for a visual pie-chart representation of the storage matrix.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.