Checking Disk Space Used in Linux – How To Use The df Command in Linux?

To check the disk space used in Linux, we’ll learn to use the df command in Linux. This is a very useful command if you’re a Linux server administrator working with multiple systems storing data. Let’s get right into it and learn to use the df command.

What is the df Command Used For?

df is short for disk-free. With this command, you can check the available space and the used space on all the filesystems that are connected to your Linux system. The command offers multiple options to display the data better. Let’s look over the different command options now.

Command Options for the df Command

By default, the df command displays all the information in bytes. The days of bytes are really over and with terabytes and petabytes of data storage, understanding data in bytes is very difficult. Let’s see what it looks like on a Linux system with a comparatively small file storage space.

root@HowLinux:~# df
Df Command Default Usage
Df Command Default Usage

As you can see, it’s just very inconvenient to understand this output. Let’s see what we can do to make the output look prettier.

Displaying df Output in Human Readable Format

The df command doesn’t leave us to ourselves, but instead, offers us the -h option. When the df command is run with the -h option, the output suddenly starts making sense. Let’s see how it looks.

root@HowLinux:~# df -h
Df H Option
Df -H Option

That’s much better! But it just lists out the names of the filesystems on the left, the sizes, and the mount points. How do we find the file system types?

Using The df Command To Output Filesystem Types

The df command gives us a very handy option -T or –print-type to list an additional column with the filesystem types. Let’s run the command below.

root@HowLinux:~# df -T
root@HowLinux:~# df --print-type
Df Print Type Option
Df Print Type Option

Notice the second column now has the filesystem types. That’s great! Now I don’t want to see all the filesystems, but only the ones that are ext4 formatted. These are the filesystems where my persistent data lies. All other filesystems in the above example (tmpfs and devtmpfs) are temporary storage filesystems and will be wiped clean when the system is restarted.

Viewing Storage Data By Filesystem Type

To view only the storage used by a specific filesystem, and not outputting anything else, we will make use of the -t or –type= options.

root@HowLinux:~# df -t ext4
root@HowLinux:~# df --type=ext4
Df Filesystem Type
Df Filesystem Type

Great, now we know how to display filesystem usage by filesystem type. Now let’s also display the total disk usage in a human-readable format.

Excluding Specified Filesystems From The Output

We learned how to view output for specific filesystems. Now let’s see how we can output everything while excluding a specific filesystem. For this, we’ll make use of the -x option.

root@HowLinux:~# df -x ext4
Df Excluding File Systems
Df Excluding File Systems

Displaying Total Disk Usage Using df Command

We’ll make use of the –total option to list out the total disk usage. We’ll combine it with the -h option to make it easier for us to view the size.

root@HowLinux:~# df -h --total
Df Total File Usage
Df Total File Usage


As time has progressed, many new GUI-based utilities have been introduced for the Linux operating system which allows you to view filesystem details without really having to enter any commands in the terminal. But when using such a powerful operating system, you will find yourself needing the terminal very often if not all the time.

So, even though there are always going to be GUI replacements for a terminal functionality, getting used to all the commands at least at their basic level will be very handy for you. And if you need to understand a command in-depth, don’t forget to refer to the man pages. Learn how to access man pages in Linux.