How ToLinux

13 df Linux Commands With Examples


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, 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 with these tips and tricks.

Read the full article: 13 df Linux Commands With Examples

I post weekly videos to my YouTube Channel, and the videos could be anything from the latest Tech News, Smartphone News, Gadget Reviews, Streaming Tips, VPN reviews and much more!

Show More


Lee TV is a Tech Enthusiast, Gadget Geek and Content Creator for the Lee TV website and YouTube channel! Lee TV is the publisher of this site, and also runs other sites in the gaming community. Join the community on the @LeeTVTech Twitter community, and the LeeTVOfficial YouTube channel!

Related Articles

Leave a Reply

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker