What is your disk usage?

In Linux, if you want to find out what your disk usage is by directory, in order to see what the heck is filling up your hard drive, try this at the command prompt:

du -s * | sort -nr > diskusage.txt

the, type in:

gedit diskusage.txt

(or whatever you need to type in to open your favorite text editor)

the -s option is to “summarize” the data, giving only a total.


  1. #1 Joe Shelby
    April 10, 2009

    I’m really “old school”:

    du | xdu &

    but I suppose xdu isn’t automagicly provided on distros anymore. As I’ve written before, one of the reasons I hate Linux today is that all of the tools I found most useful keep disappearing, as if every time a new distro or desktop comes out, they reinvent the wheels and in doing so get rid of the one feature that made the preceding tool actually worth using.

    If I had the time and gave a crap, I’d write my own admin tool that would give me back all of the useful GUIs that the distro-makers and desktop-makers keep taking away from me, just to show ’em.

    But I no longer have the time to give a crap. Linux had its chance, but just like Windows 8 years ago (when I was at my Linux peak), not knowing where anything is (again) is just getting in the way.

    Not that vista nor the mac are that much better. Vista’s hidden way too many things, and the Mac keeps reinventing itself every 5 years with the complete “learned experience? who the hell cares?” attitude that will someday bite them on the arse.

    One of the coolest tools I ever used (over 15 years ago) was the Motif version of SMIT for the AIX/6000 platform. Why the hell doesn’t anybody write cool shit like that for end-user administration anymore?

  2. #2 Anthony
    April 10, 2009

    If I’m trying to figure out why a disk has suddenly become full, I’m fond of find -size 1000 -mtime -7 -ls

    Alter numbers to taste. Shows you all files over 1,000 blocks (generally 500k) that have been modified in the past week. Useful for spotting the log file that is being filled up with garbage, and similar issues.

  3. #3 Ben Zvan
    April 10, 2009

    I use “du -sh *” for human readable. It breaks “sort” though.

  4. #4 Chris M
    April 10, 2009

    you may wish to add the -m or -g flag to du as well to nicely format the size by GB or MB rather than byte.

  5. #5 Tony Sidaway
    April 10, 2009

    I usually go looking for big files with, say, find . -size ‘_10M’ -ls

  6. #6 Greg Laden
    April 10, 2009

    Joe: xdu has been supplanted for some time by xdiskusage, and the latter is a GUI program, so really, not geeky enough…

  7. #7 Joe Shelby
    April 10, 2009

    Well, it’s the “supplanted by” thing that kept getting me, especially when “supplanted by” translates to “oh, and it’s not nearly as good, either”. 😉

  8. #8 Greg Laden
    April 10, 2009

    I just installed and ran xdu and xdiskusage, and they really are different from one another. The latter is slicker and cleaner but is not really as graphically useful as the former.

  9. #9 jpmcg
    April 11, 2009

    Nice, useful. Thank you.

  10. #10 Peter Lund
    April 11, 2009

    Isn’t Baobab much nicer?


    It’s placed in the Applications|Accessories menu under the name “Disk Usage Analyzer” on my (old) Ubuntu installation.

    (It’s part of the gnome-utils package)

  11. #11 Wayne Conrad
    April 11, 2009

    Joe said: “but I suppose xdu isn’t automagicly provided on distros anymore.”

    In Debian, “apt-get update && install xdu” and you’ll have it. As in most distributions, the list of available packages is so large that it’s inconceivable that the distributions should install them all. There are good reasons to not automatically install every tool that everyone might every want. Sometimes I’m just creating a firewall with an old, small hard drive and don’t want to expend the space, time and bandwidth it takes to install everything ever written. Let’s flip this around: Do you want to have every package that Joe thinks is required installed? And that Tom thinks is essential? And Susan? Because that leads to having everything installed, and makes a distro installation a monster, unsuitable for many purposes.

    In Debian, It’s pretty easy to make your own meta-package that does exactly what you’re thinking of (just requires your favorite packages). If it’s easy in Debian, I’ll bet it’s easy in other distros as well.

  12. #12 Wayne Conrad
    April 11, 2009

    An error in my post: It should be “apt-get update && apt-get install xdu”

  13. #13 GaryB
    April 11, 2009

    Thanks Greg.

    You find the best information at the oddest of places. Not that you’re odd or anything.

  14. #14 BruceH
    April 13, 2009

    Also, if you don’t want to bother with a text file, but still want a readable output, you can pipe it to less. (or more, but I think less is better.)

    du -s * | sort -nr | less