Build a Better Process

Linux df Command Summary with Examples

Linux df allows you to display file or file system space.
  1. Purpose - Learn what df is for and how to find help.
  2. Options - Review a few common options and examples.
  3. Examples - Walk through code examples with df.
  4. A tip - Finish off with one more insight.
face pic by Paul Alan Davis, CFA
Updated: February 24, 2021
In this tutorial on Linux df, 51 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / df-command.html

An ad-free and cookie-free website.

Examples of the Linux df Command


Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux df Command Summary with Examples (3:44)

Video Script

The Command and Why You Need It

Our fifty-first word, or command to memorize is df from our category System.

df allows you to display file or file system space.

Common Linux df Options
-options description
--help Print help screen
-h, --human-readable Print size in units of 1024 (one kilobyte)
--output=FIELDS Report only specified FIELDS

Recall from the last video on stat, we looked at permissions, timestamps and file system size, well here we'll focus on size and usage statistics.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The df command has 18 options and the argument is the file or file system name.

Like most commands, help is available with double-dash --help, -h reports in human-readable form, like 1k for 1 kilobyte, 1M for one megabyte, 1G for 1 gigabyte.

And to report specific items, we can use --output=FIELDS.

So why is df an important command? Well, space is a limited resource and nobody likes to run out, so we periodically need to check in on our allocation. And now you know how to do that.


Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. So to illustrate the difference between entering files or file systems, let's do a quick df on the file system located in devices at /dev/sdb1.

$ df /dev/sdb1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 5028480 10632 4739372 1% /home

Or refer to it as our home directory using /home.

$ df /home Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 5028480 10632 4739372 1% /home

Same thing, right? But now let's work on this because this isn't user-friendly.

Now we'll make it more friendly, using the -h option.

$ df -h /home Filesystem Size Used Avail Use% Mounted on /dev/sdb1 4.8G 11M 4.6G 1% /home

We all understand this 1%, but most of us think in terms of gigabytes and megabytes. Beyond that, we don't care to get more granular.

And last, let's tack on the --output option with ='size','pcent' coded up like this for the /home directory.

$ df -h --output='size','pcent' /home Size Use% 4.8G 1%

And voilà. The information we really care about.

A Final Tip

Okay now you know how to use df. And you know the syntax for commands, options and arguments.

One last tip about the df command. So I suggest starting to think of a use case, like using df to kick off an email to users who are nearing their capacity.

Okay, thanks for visiting today. I hope this was a helpful introduction to the df command.

Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:

What's Next?

If you learned something today, please consider subscribing at YouTube, following @factorpad and joining the email list. Every bit of support expands free access to FinTech learning.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / df-command.html

linux df command
df linux
linux df
unix df
df unix
linux df examples
man df
df command
disk usage linux
df linux command
linux disk space usage
linux command disk space
linux free disk space
linux free space
linux df tutorial

A newly-updated free resource. Connect and refer a friend today.