Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Disks and Filesystems

Linux df command

Reference for the Linux df command: show size, used and available space per filesystem, use -h, -i and -T, pick columns with --output, and avoid common surprises.

df ("disk free") reports how much space each mounted filesystem has, how much is used and how much is left. It asks the filesystem itself, so it is fast and shows the real picture even when files are spread over many directories. To find out which files use the space, use du.

Give it a file or directory and df reports on the filesystem that contains it, which answers the practical question "is there room to write here?".

Terminal
df [OPTION]... [FILE]...

Try it

Bash Layouts and options

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Using df in scripts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
df [-h | -H | -k | -m | -B SIZE] [-a] [-i] [-l] [-P] [-T] [-t TYPE] [-x TYPE] [--total] [--output[=FIELDS]] [FILE]...
Option Description
-h Human-readable sizes with powers of 1024 (1.5G).
-H, --si Same, with powers of 1000.
-k, -m Force 1 KiB or 1 MiB units. -B SIZE sets any block size, such as -BG or -B1.
-i Report inodes (file count capacity) instead of blocks.
-T Add a column with the filesystem type.
-t TYPE Only list filesystems of this type. -x TYPE excludes a type. Both are repeatable.
-l Only local filesystems, skip network mounts.
-a Include pseudo, duplicate and inaccessible filesystems that are hidden by default.
-P POSIX output: one line per filesystem, 1024-byte blocks by default, never wraps long names.
--total Add a grand total line.
--output[=FIELDS] Choose columns: source, fstype, itotal, iused, iavail, ipcent, size, used, avail, pcent, file, target.
FILE Report on the filesystem holding this file or directory.

Returns: 0 if all operands could be read; 1 if any failed (for example a path that does not exist).

Usage notes

  • Used + Avail is less than Size. Ext filesystems reserve about 5 % of blocks for root by default, so ordinary users can run out of space while Size - Used still looks positive. The Use% column is calculated against what non-root users may use.
  • 100 % use with free space left is possible in another way: running out of inodes. A directory with millions of tiny files can make df -h look fine and df -i show 100%. Writes then fail with "No space left on device".
  • Deleted but open files keep their space until the last process closes them. df shows the disk as full while du cannot find the files. lsof +L1 lists them (see lsof).
  • Different numbers than du. df counts allocated blocks of the whole filesystem including metadata and journals; du adds up the files it can see. Small differences are normal.
  • Containers and overlays. On overlay filesystems the numbers describe the host disk that backs the layers, not a per-container quota.
  • tmpfs and other memory-backed mounts (/dev/shm, /run, sometimes /tmp) show their configured size; they only use memory for the data actually stored.
  • Slow on stale NFS mounts. df stats every filesystem, and a hung network mount can block it. Use df -l or name the path you care about.
  • Scripting. Use --output= with tail -1 instead of cutting columns by position; names with spaces break awk '{print $5}'.
  • Snapshots and compression (Btrfs, ZFS) make df approximate; use the filesystem's own tools for exact accounting.