10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Hosting referral link if you planning to start your blog ($3.82/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Ravi Saive

I am Ravi Saive, creator of TecMint. 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. Follow Me: Twitter, Facebook and Google+

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

25 Responses

  1. Stranger says:

    Does any one know or experienced the output of “du -csh” mismatched with grand total ?

    For ex: du -csh *
    10M File_A
    14M Dir_A
    22M total

    but expectation is 24 MB as total.

  2. Cedric says:

    I would like to mention also this combination, in order to find the biggest sub-folders in current location:

    du -h –max-depth=1

    thanks

    • no one in particular says:

      Yes – I ended up going to an ancient site looking for that switch – it should be like number 2 on the list.

      fyi: On some systems – freebsd is particular, depth is just -d [depth] – so “du -d 1 -h” is the secret sauce for the question ‘wtf happened to my space?’

  3. rlinux57 says:

    Is is possible to collect historical data analysis of disk space usage per user ?

    • Ravi Saive says:

      @rlinux,

      No you can’t use du (disk usage) command to get the disk space usage per user, yes but you can do use some command-line tricks with the help of find and awk command to find out the disk space usage for all users on the system including root user, here is the command.

      # find . -printf "%u  %s\n" | awk '{user[$1]+=$2}; END{ for( i in user) print i " " user[i]}'
      
      • rlinux57 says:

        But i need want to get the historical disk space usage, not current usage.

        • soft says:

          You could start a cron to run this command at different times to log the historical data
          find / -printf “%u %s\n” | awk ‘{user[$1]+=$2}; END{ for( i in user) print i ” ” user[i]}’

          • soft says:

            find / -printf “%u %s\n” | awk ‘{user[$1]+=$2}; END{ for( i in user) print i ” ” user[i]}’ > /yourlogdir/log_`date +_%m_%d_%Y_%H%M%S`

  4. rosh says:

    Another nice option is to sort by size: du -h * | sort -h

  5. Ashish Karpe says:

    how to find du of / ie when I ran du -sh / it gives du: cannot access `./proc/14498/task/14518/fdinfo/35147′: No such file or directory
    du: cannot access `./proc/14498/task/14518/fdinfo/35156′: No such file or directory

  6. Yasminhth says:

    Thanks for tips. Well explain ans example

  7. abhi says:

    very nice work. It helped me.

Got something to say? Join the discussion.

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

Join Over 300K+ Linux Users
  1. 257,757
  2. 11,967
  3. 39,682

Are you subscribed?