13 df Linux Commands With Examples

Christian Cawley 07-12-2019

Getting to grips with Linux can be tough for newcomers. But the power of command line tools should not be overlooked. They may look old fashioned—requiring zero mouse use—but tricks like the df command can save you time.


With the Linux df command you can easily interrogate your system for details on disk space and file size. These 12 df command examples will show you how.

What Is the df Command in Linux?

If you want to know how much disk space is free on your Linux PC, what is your first instinct? For many it might be to check your Linux distro’s disk management tool, but this isn’t the best option. Just as there is a data duplicator tool for cloning disks How to Easily Clone and Restore a Linux Disk Image With dd If you want to wipe, backup, or restore data on Linux, there are a number of apps you can pick. But whichever Linux operating system you run, there's one command that always works -- dd. Read More , there is also a “disk filesystem” tool for checking details about the filesystem.

This is the df command, entered in the bash terminal. It can be used in so many ways:

  1. Display disk space usage
  2. Display usage on a specific device
  3. Show all file systems in use
  4. Find disk information on a specific file
  5. Display inodes
  6. Show the file system on a specific file
  7. Include file system types
  8. Exclude file system types
  9. Display the df command help file
  10. Show grand total disk usage and free space

The df command can also be tweaked to display file sizes and free space in kilobytes, megabytes, and gigabytes.

The df Command Syntax

Before you start using the df command, be aware of its syntax. Like most Linux terminal tools, it is straightforward; knowing it will save time as you use df more often.


You can check the df command syntax manually with the help command:

df --help

You’ll see the first line:

Usage: df [OPTION]... [FILE]...


So, you would use df followed by the [OPTION] then any relevant [FILE] or directory. These are listed in the help file, but you can keep reading to see some examples demonstrated.

1. Display Disk Usage With the df Command

Linux df command output

To display your computer’s disk space, which results in file system type, used and available space, and more, use:



2. Display Disk Usage for a Specific Drive With df

You can get more specific by selecting a specific drive or partition. Simply add the file path as the [OPTION]:

df /home

3. Display All File Systems With df

Display all filesystems with the Linux df command

The default df command only shows standard file systems on your computer. Inaccessible file systems, duplicates (in a RAID system for example) and pseudo file systems are ignored.


However, you can display these using df. Just use the -a switch, for “all”:

df -a

4. Find Information for a Specific File

Looking for data concerning a specific file? If you need to know where a particular file is and the remaining space on the device it is stored on, use:

df /home/christian/file.txt

This is useful when tracking down data to move between hard disk drives. For example, you might be migrating important personal data to a secondary drive or partition.

5. Display Inodes With df

Inodes are key to Linux file systems, storing information about files much like a database. To show information about inodes input

df -i

6. Use the df Command to Display File System

Linux df command with the -T option

Need to know what file system type is in use on your drives? Use the -T option, followed by a file path.

df -T /home/christian/file.txt

Look for the Type column heading. As you can see in this example, the filetype is ext4.

7. Include and Exclude File System Types with df

As well as displaying file system types with df, you can also include specific types. For example, if you wanted to display all ext4 file system devices use:

df -t ext4

8. Exclude File System Types

Want to exclude a file system type? To display all file system types on your drive except ext4, use:

df -x ext4

9. View Grand Total Disk Usage With the df Command

View totals with the Linux df command

While the basic df displays a summarized total of disk usage, it doesn’t include hidden files. To see this figure instead, use

df --total

10. Check the df Command Help File

While most df commands can be found in this list, you’ll find some additional, rarely used examples in the help file. View this with

df --help

Bonus: Display df Results in KB, MB, and GB

In addition to all of that, the df command can be tweaked slightly to deliver more readable results. By default, the output is in bytes. If you know how bytes relate to megabytes and gigabytes, this may not be an issue for you.

Switch output of the Linux df command to kilobytes

However, for readability it is a smart option to use these switches:

  • Make the standard output readable to humans familiar with GB numbering with -h
  • Display df command output in megabytes (MB) with -m
  • You can also display output in kilobytes with -k

Usage is straightforward—the option appears in the specified position, alongside any others that are selected if necessary. For the basic df command, use

df -h

If you want to see the size of a specific file in GB rather than the default bytes, use the file path and filename:

df -h /home/christian/file.txt

The df Command Is Key to Successful Linux Use

By now you should have gained some familiarity with the df command. Yes, you can live without it and perhaps find the info you need in the file manager. But with as little as two keystrokes you can also find the information in the terminal.

As typing is almost always faster than using a mouse, it makes sense to have this command line trick ready.

Want more Linux terminal commands like df? Become a Linux command line master Become a Linux Command Line Master With These Tips and Tricks Whether you're brand new to Linux, or a seasoned Linux veteran, the command line offers a bevy of uses. Try these tips for mastering the command line. Read More  with these tips and tricks.

Related topics: Command Prompt, Linux Commands, Terminal.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Sanjay Chakraborty
    November 5, 2019 at 6:35 pm

    df -- o will give you all you need.

  2. Sanjay Ch3
    November 5, 2019 at 6:33 pm

    df --o will give all your need.
    - Sanjay Chakraborty