Mastering the Linux df Command: Practical Examples for Disk Space Management
This guide explains how to use the Linux df command with real‑world examples, covering human‑readable output, inode statistics, total usage, filesystem types, inclusion/exclusion filters, specific mount points, and virtual filesystems to help you monitor disk space effectively.
Overview
The df command reports disk space usage for mounted filesystems on Linux. It can display information in various formats, making it a versatile tool for system administrators and developers who need to monitor storage.
Human‑Readable Output
By default df shows sizes in 1‑kilobyte blocks, which can be hard to read. Adding the -h option prints sizes in a human‑readable format (e.g., 100K, 200M, 3G).
$ df -h Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu-root 909G 565G 299G 66% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 3.9G 4.0K 3.9G 1% /dev
...Displaying Inode Usage
Inodes store metadata for files. A filesystem can run out of inodes even if space remains, especially when many small files exist. Use the -i option to view inode statistics.
$ df -i Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/ubuntu-root 60514304 1217535 59296769 3% /
...Total Disk Usage Across All Filesystems
To see the combined usage of all mounted filesystems, add the --total flag.
$ df -h --total Filesystem Size Used Avail Use% Mounted on
... (individual lines) ...
total 918G 565G 307G 65% -Showing Filesystem Types
The -T option adds a column with the filesystem type (e.g., ext4, tmpfs).
$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root ext4 952893348 591583292 312882844 66% /
...Including or Excluding Specific Filesystem Types
Use -t to include only certain types (repeatable) and -x to exclude types.
$ df -t ext2 -t ext4 Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root 952893348 591583380 312882756 66% /
/dev/sda1 233191 100025 120725 46% /boot $ df -x tmpfs Filesystem 1K-blocks Used Available Use% Mounted on
... (output without tmpfs entries) ...Querying a Specific Mount Point or Path
Providing a mount point or any file/directory path makes df report the filesystem that contains it.
$ df / Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root 952893348 591583528 312882608 66% / $ df /home/dev Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root 952893348 591583528 312882608 66% /Including Virtual Filesystems
Virtual filesystems (e.g., proc, sysfs, tmpfs) have no physical storage. Use -a to list them as well.
$ df -a Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu-root 952893348 591578716 312887420 66% /
proc 0 0 0 - /proc
sysfs 0 0 0 - /sys
...Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
