12 Useful “df” Commands to Check Disk Space in Linux

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators

Ravi Saive

Simple Word a Computer Geek and Linux Guru who loves to share tricks and tips on Internet. Most Of My Servers runs on Open Source Platform called Linux.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Ubuntu Linux Toolbox: 1000+ Commands

You may also like...

11 Responses

  1. Frederik Krautwald says:

    Very useful. Thanks.

  2. Iyan says:

    Thanks so much Ravi!

  3. Tim says:

    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.

  4. Garion says:

    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

    )

  5. kunal says:

    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

  6. 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!

    • Tim says:

      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.

  7. Mayur says:

    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.

  8. Bruce says:

    watch df -h for keeping an eye on active disk growth or shrink if you are running batches.

  9. duan says:

    very clear,good article,thanks for sharing

  10. slappy says:

    df -P is usefull too

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Join Over 70000+ Linux Users
  1. 48590
  2. 2375
  3. 13200

Enter your email to get latest Linux Howto's