/ factorpad.com / tech / linux-essentials / df-command.html
An ad-free and cookie-free website.
Beginner
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux df Command Summary with Examples (3:44)
Our fifty-first word, or command to memorize is
df
from our category
System.
df
allows you to display file or file
system space.
-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
.
Or refer to it as our home directory using
/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.
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.
And voilà. The information we really care about.
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.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
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.
stat
command,
hit Back.du
, click Next./ factorpad.com / tech / linux-essentials / df-command.html
A newly-updated free resource. Connect and refer a friend today.