Look at your disk space with 'df' command in Linux

It doesn't matter if you are a system administrator or a regular desktop user, you need to know how much disk space you have available or used for everything to work properly on your system.

If you are using Linux for the desktop, this can be done with a regular file manager, but the Linux user needs to know the command line and make the most of it. This is why you need to know and understand a little more about the "disk format" or "df" command.

Using the df command to check disk space on Linux

Let's see how you can use the df command to get various information about disk space on Linux.

Just press df to see disk information

The basic and simple "df" command will list a complete list of file systems in your Linux installation. We'll probably need a whole article to explain what a filesystem is, but for now, let's assume this is a way to organize some of the files on your system.

This information will probably not be the best in terms of readability, so let's take a look at the best version.

A human-readable version of "df -h"

To get a "human-readable" version of the output (which is what "h" stands for), you must run "df -h".

df -h

This will give you something like this:

As you can see, it lists file systems and uses gigabyte and megabyte units to represent space, which is much easier to understand and work with.

List types for each filesystem

It would be helpful to list the filesystems with the appropriate filesystem type for each. For this you can use the "-T" option:

df -T

Check free disk space on Linux using the df command

Sometimes you want to know how much disk space is available for a particular folder on your system in the filesystem that folder is located in, so you can find out simply by using "df" with the folder you want to know about.

df -h dirname

This should not be confused with knowing how much space this folder actually takes on the system, as this information will not be provided by the "df" command, but by the "du" command (disk usage). However, this df option will actually give you an idea of ​​how much space you have available for that particular folder and what filesystem it is on.

Exclude a specific type of file system

We have seen that "df" will give you a lot of information, but sometimes less is more, and you can exclude several types of filesystems to get only certain data.

In my previous example, you can see that I have a lot of "bindings" installed, and each one is listed separately. They all have a "squashfs" filesystem, so if I filter them to NOT include, I get more limited information:

By using the "x" (exclusion) option, I can remove the file system types from the output to get more specific information.

df -x filesystem_type

List of specific filesystems only

On the other hand, let's say you want to list only certain types of filesystems, so instead of excluding all the ones you don't need, just list the specific one you want.

There is an option for this which is very simple: just add "-t" and the type of filesystem you want to specify.

df -t file-system_type

Lesson summary

As you can see, the "df" command is a very useful command that you should know to be able to get more information about your disk space. This is not just a matter of having available disk space, it also gives you many opportunities to learn about specific filesystems and display information in a variety of formats.

Of course, as with any command, you can see some of the other options it has by simply running the "-help" option on it:

Do you think there are other useful options or use cases for the df command in Linux? Leave me a comment below and don't forget to share this article with anyone you think might benefit from it.

Share this Post:

Want a Consultation or an Advice? Ask a MivoCloud Expert. It's Free.

Our customer support is ready 24/7/365 to help you. Don't guess, just ask now. Contact Us