12 Linux ‘df’ Commands to Check Disk Space Usage

On the internet, you will find plenty of tools for checking disk space usage in Linux. However, Linux has a strong built-in utility called ‘df‘.

The ‘df‘ command stands for “disk filesystem“, it is used to get a full summary of available and used disk space usage of the file system on the Linux system.

Using ‘-h‘ parameter with (df -h) will show the file system disk space statistics in “human-readable” format, which means it gives the details in bytes, megabytes, and gigabytes.

This article explains how to get the full information on Linux disk space usage with the help of the ‘df‘ command with their practical examples. So, you could better understand the usage of the df command in Linux.

1. Check Linux Disk Space Usage

The “df” command displays the information of device name, total blocks, total disk space, used disk space, available disk space, and mount points on a file system.

sudo df
Show Linux Disk Space Usage
Show Linux Disk Space Usage

2. Check Information on Linux Disk Space Usage

The command "df -a" is used to display information about all the mounted filesystems disk space usage, which includes total space, used space, available space, memory utilization, and the percentage of space used for each filesystem.

It also shows pseudo filesystems with 0 blocks (those not directly tied to a physical device) and are ignored by default.

df -a
Show Information of Disk Space Usage
Show Information on Disk Space Usage

3. Show Disk Space Usage in Human Readable Format

Have you noticed that the above commands display information in bytes, which is not readable at all because we are in a habit of reading the sizes in megabytes, gigabytes, etc. as it makes it very easy to understand and remember.

The command "df -h" is used to display disk space usage in a human-readable format. The "-h" option stands for “human-readable” and it shows information about all mounted filesystems on your system, presenting the sizes in a format that is easier for humans to understand, using units like kilobytes (KB), megabytes (MB), gigabytes (GB), etc.

sudo df -h
Show Disk Usage in Human-Readable Format
Show Disk Usage in Human-Readable Format

4. Check Disk Space Usage of /home Directory

The command "df -hT /home" is used to display disk space utilization of /home directory or partition in a human-readable format. The -T option shows the filesystem type (ext4) along with other information.

df -hT /home
Check /home Directory Disk Space
Check /home Directory Disk Space

5. Check Disk Space Usage in Kilobytes

To display all mounted filesystem information and usage in 1024-byte blocks, use the option ‘-k‘ (e.g. --block-size=1K), which provides information about each filesystem on your system, presenting sizes in kilobytes (kb).

sudo df -k
Disk Space Usage in Kilobytes
Disk Space Usage in Kilobytes

6. Check Disk Space Usage in Megabytes

To display information on all file system usage in MB (MegaByte) use the option ‘-m‘, which presents sizes in megabytes (MB).

sudo df -m
Disk Space Usage in Megabytes
Disk Space Usage in Megabytes

7. Check Disk Space Usage in Gigabyte

To display information on all file system statistics in GB (Gigabyte) use the command "df -h", which shows disk space in human-readable sizes such as kilobytes (KB), megabytes (MB), gigabytes (GB), and so on.

sudo df -h
Disk Space Usage in Gigabytes
Disk Space Usage in Gigabytes

8. Check Inode Usage in Linux

The command "df -i" provides detailed information about the number of inodes used and available on each mounted filesystem on a Linux system. The inodes are data structures that store information about files and directories, such as ownership, permissions, and timestamps.

sudo df -i
Check Inode Usage in Linux
Check Inode Usage in Linux

If you find yourself in a situation where there is a shortage of inodes, you will need to increase the inode count on your Linux filesystem.

9. Check Linux File System Type

If you notice all the above commands output, you will see there is no Linux file system type mentioned in the results. To check the file system type of your system use the option ‘T‘, which will display file system type along with other information.

sudo df -T
Show File System Type
Show File System Type

10. Check Disk Space Usage for ext4 Filesystems

If you want to display a certain file system type use the ‘-t‘ option, which will display disk space usage specifically for filesystems of type ext4.

sudo df -t ext4
Check Filesystem Type Disk Usage
Check Filesystem Type Disk Usage

11. Exclude Certain File System Type

If you want to display a file system type that doesn’t belong to the ext4 type, use the option ‘-x‘, which will print disk space usage for all mounted non-ext4 filesystem filesystems excluding those of type ext4.

sudo df -x ext4
Exclude File System Type
Exclude File System Type

12. Check df Command Usage

The command "df --help" provides a list of available option that is used with the df command.

df --help
df Command Help
df Command Help
Conclusion

The ‘df‘ command is useful for checking disk space utilization on your Linux system. By running various options such as '-h' for human-readable output or '-T' to display filesystem types, users can obtain detailed information about the disk space usage across different mounted filesystems.

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

54 thoughts on “12 Linux ‘df’ Commands to Check Disk Space Usage”

  1. The ‘df‘ command stands for “disk filesystem

    This is incorrect. ‘df‘ stands for “disk free“.

    Reply
  2. Hello all,

    I am a newbie to Linux. I am using CentOS 7 in VMWare.

    I tried df -th xfs and got an error as

    "  df: 'xfs' : No such file or directory.  "
    

    But when i reversed the flags and did ‘df -ht xfs‘, I got the proper output.

    So my question is that do we have an overriding concept when it comes to flags as I was confused that why in it showed no such file error with -th? option?

    Reply
  3. Achtually, if you want to be super correct df -h shows usage in Gibibytes, df -H shows Gigabytes. The difference gets noticeable at high amounts and people are more used to thinking in Giga rather than Gibi no matter how much computer techs would prefer it to be the other way around.

    Reply
    • You have put the details other way around -h uses 1024 where as -H uses powers of 1000. -H numbers would be significantly higher than -h.

      Reply
      • I don’t see I left any details on which one is bigger in my original comment. People do get confused when you tell them they have fewer GiB (1024) than they expected since they are used to the smaller GB (1000).

        Reply
        • And here in lies the problem with this nonsense called gibibytes etc.
          I am a computer tech and no other computer techs I know (under the age of 30), give this ridiculous notion of a megabyte being 1000×1000 any time of day.
          Sorry but a megabyte WILL ALWAYS be 1024 kilobytes (1024 bytes) x 1024 kilobytes no matter how hard the push is to rename computing standards to fall in line with other standards of measurements i.e kilogram, kilometre etc

          It’s a real pity that in Linux you can’t show file sizes in traditional/correct megabytes, gigabytes etc
          I see Gibibyte and I think Gigabyte. THAT and mass confusion is all this nonsense has achieved.

          Reply
  4. Why is “df -hT /home” giving me the same exact results as “df -hT /” ?

    “/” should be the root folder and “/home” should be a directory underneath root (“/”) but I am getting the same exact results down to the byte level.

    In any case, decided to use “df -h –type=ext4” so that I can be sure I can see the entire space available to me. The other filesystems are for the system to manage directly (ex: udev, tempfs and none). “none” is referring to /sys/fs/cgroup and a couple of /run/* directories.

    Reply
    • @Jamesh,

      The df command used to display disk usage of File system, not a directory, here /home not a filesystem or partition, that’s the reason its showing / usage..

      Reply
    • Indeed and #7 is just downright wrong. “Displays in GB”. It displays in whatever unit it deems best, it will show TB or MB too. Even the example they have demonstrating #7 shows two filesystems/mount-points in MB!

      Reply
  5. I have a file system that is not a Mount Point and does not show up when “df” is executed….. Is there a command to show the file allocation and utilization for a file system that is allocated space, but, is not configured as a Mount Point?

    Thanks,
    Andy

    Reply
      • Hi Ravi,

        According to Andy he said the file system is not on a mount point.

        to access any filesystem it should be mounted right.

        If its only about allocation u can use fdisk or parted if its a physical partition / lvs or lvscan if if its a LVM one.

        thanks
        Mohideen

        Reply
  6. I used man df for help.. and I am not sure how to exit from help. I tried esc button, It shows end. Can you help me to exit from the help menu. Ofcourse for how close the terminal.

    Reply
    • @Satish,

      Just press ‘q‘ keystroke to exist from the man pages in the linux from the commandline. I hope it will resolve your issue and keep connected to tecmint for such awesome articles..

      Reply
  7. Thx, this saved me a lot of work and helped me to solve some problems. I’ll save this article to my bookmarks, you always need all kind of linux commands.

    Reply
  8. Thanks Ravi for explaining in detail. I being a newbie was lil worried using the Linux Commands. The explanation really helped free 15 GB of data on my server. Cheers !

    Reply
  9. If your df differs from du -csm /mountpoint, check for deleted files still opened (so still on disk, seen by df, but not du) with lsof :
    lsof |grep deleted

    For an online disk usage report you can also try http://www.diskreport.net
    With periodic reports you can get graphs of size changes for each directory, very usefull to find growing files

    Reply
  10. Just a note — #5 shows “in bytes”.. it really should say “in kilobytes”. If you want to show the filesystem size in bytes, you need to set the blocksize to 1 (not 1K).

    I’m working on a project now where they want the filesystem size in bytes, and I was surprised to see that ‘df’ doesn’t natively support that.

    Reply
  11. Hi, I came across this script (http://www.systemtoolbox.com/article.php?articles_id=1023)for iterating through a server list file and mapping each of the server drives indicated and takes a snapshot of the df information and appends it to a file named relative to server and drive letter.

    However, it seems the script is not working or complete. I would appreciate if someone can help explain to me hoe to use it. I am looking for the destination of the text file created and appended with the server and drive information. Thanks.

    for /f “tokens=1,2 delims= ” %%A in (drives.lst) do (

    echo %%A %%B

    net use x: /del temp.txt

    type temp.txt | cut -f2 -d: | cut -f2 -dG > temp2.txt

    for /f %%Q in (temp2.txt) do (

    echo %%Q >> %%A-%%B.txt

    )

    del temp.txt

    del temp2.txt

    )

    Reply
  12. Hallo ravi,

    I have one question that how we can check disk only free or only occupied free space of disk and then make if condition like

    If(Free space == 20% ) then

    do this action

    else
    null
    fi

    Reply
  13. Wow, thanks a lot! This helped me out a lot but I couldn’t find out how to see how much disk space a certain directory is using. I tried “df -hT /var/www/vhosts/domain” but it didn’t show me. :( But other than that this article has helped me a lot. Thank you!

    Reply
    • A directory is not the same thing as a filesystem. ‘df’ shows filesystem information. The directory /var/www/vhosts/domain is likely a directory on the /var filesystem, so issuing a ‘df’ there will show you stats for /var. If you want disk usage for a particular directory, use the ‘du’ command. The man page should give you the information you need.

      Reply
  14. Our vendor has finished installing redhat OS on our servers & has submitted a machine installation report. When I verify the file system using df -h , the sum of the size of the file systems as shown in the output is greater than the actual HDD size allocated to that virtual machine. But when I use fdisk -l|grep Disk, the size shown in output matches with the hdd size. Can you please help me out as to how do I verify the file system ??

    My aim is to match the HDD size allocated to particular Virtual machine with the total size all file systems on that VM.

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.