How to Check Disk Space in Ubuntu

The File System Allocation Interrogation

When operating a headless Ubuntu server, you lack a graphical pie chart to warn you when your solid-state drive is nearing maximum capacity. If a rogue Node.js application begins writing an infinite loop of `.log` files, or a MySQL database expands beyond its allocated partition, the server will mathematically crash the microsecond it attempts to write a byte to a 100% full drive. You cannot wait for a failure; you must proactively instruct the Linux kernel to execute a mathematical interrogation of every mounted block device, pulling exact block-level data regarding total size, used space, and available capacity.

How to Check Disk Space in Ubuntu

The UNIX architecture utilizes two distinct, highly optimized C-binaries for disk telemetry: `df` (disk free), which calculates overall partition capacity, and `du` (disk usage), which calculates the exact byte size of specific directories.

1. Open your terminal application or connect to the server via SSH.
2. Method 1: The Master Partition Interrogation (`df`):
* This is the mathematically superior method for understanding your overall server capacity.
* The standard `df` command outputs raw data in 1K blocks, which is mathematically difficult for a human to parse. You must inject the `-h` (human-readable) flag to force the kernel to output the data in Megabytes (MB) and Gigabytes (GB).
* Type exactly:
df -h
* Press Enter.
* The Diagnostic Dump: The terminal will output a precise mathematical grid.
* Filesystem: The specific logical volume (e.g., `/dev/sda1` or `/dev/nvme0n1p1`).
* Size: The absolute maximum capacity of that partition (e.g., `50G`).
* Used: The exact amount of space currently occupied by data (e.g., `42G`).
* Avail: The remaining free space.
* Use%: The critical percentage metric. If the primary `/` (root) mount is at 99%, an OS crash is imminent.
3. Method 2: The Surgical Directory Scan (`du`):
* If `df -h` reveals your drive is 95% full, you must locate the specific folder causing the bloat. You use `du` for this.
* Navigate to the suspected directory (e.g., `cd /var/log/`).
* Type exactly:
du -sh *
* Press Enter.
* The Execution: The `s` (summary) and `h` (human-readable) flags force the kernel to calculate the total size of every file and folder within your current directory and output the list. You might see `24G syslog`, instantly identifying the source of the capacity failure.
* (To scan the entire root directory, which will take time and require root privileges: `sudo du -sh /*`).

Get the best tech tips delivered straight to your inbox.

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