Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Check a disk usage summary to find wasted disk space UNIX

Does it ever seem like you should have more disk space but you can't see to track down where it's being used? Using Get Info to figure out where you are wasting disk space can be useful, but it's overly cumbersome when you have to get info about each item individually. It also doesn't easily reveal data stored in invisible folders.

The du Unix command is very useful in some instances, but by default runs recursively, providing too much information to be useful in a broad disk usage audit. However, if you add the following command to your .login, you wil have access to a very simple Disk Usage summary utility:


alias dus 'du -Psckx * | sort -nr'
Alternate between using this command and then cd'ing to hot spots to quickly track down what's chewing up your disk space. For instance, I found I had left a 5GB folder of video footage on OS 9's hidden 'Desktop Folder.'

Thanks to the unix gods over in the MacOSXHints forums for greatly simplifying this command for me -- it used to pipe through awk -- messy!

Warning: If you perform this request at the root ('/') of your hard drive, it will likely take a long time to get through your /dev and /Volumes folders. There's nothing wrong with doing that (and that's how I found that 5GB), but it will likely take longer.

    •    
  • Currently 2.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[40,417 views]  

Check a disk usage summary to find wasted disk space | 10 comments | Create New Account
Click here to return to the 'Check a disk usage summary to find wasted disk space' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Check a disk usage summary to find wasted disk space
Authored by: TomatoMan on Oct 10, '03 11:19:40AM
There's also a nice GUI tool by the Omni Group called OmniDiskSweeper which is useful for finding out where your disk space has gone. It gives a Finder-column-like interface, sorting very quickly by net directory size, including invisible items. In the free version, you go delete the files yourself; for the shareware fee, a fat "delete" button in the main window is enabled. Very useful for finding fat, invisible files and so forth.

[ Reply to This | # ]
Check a disk usage summary to find wasted disk space using bash
Authored by: dirkwald on Oct 10, '03 11:46:56AM
If you use bash as your shell (default in Panther IIRC), the command
alias dus='du -Psckx * | sort -nr'
should be added to your ~/.bash_profile.

[ Reply to This | # ]
Check a disk usage summary to find wasted disk space using bash
Authored by: gustou on Oct 10, '03 12:44:03PM

It also seems that
alias dus 'du -Psckx * | sort -nr'
doesn't work on Panther. you should get rid of the P option :)

You can also add the "h" option to du to have a Human readable output.
So it becomes :
alias dus 'du -sckxh * | sort -nr'
Enjoy !



[ Reply to This | # ]
Check a disk usage summary to find wasted disk space using bash
Authored by: foobar104 on Oct 10, '03 12:56:23PM

Don't use du -h and sort -n at the same time. The -n option to sort tells it to sort numerically, but the -h option to du keeps it from returning a number. If you du -h and sort -n, you end up with a list that puts 12K in front of 11G, which isn't what you wanted.



[ Reply to This | # ]
Check a disk usage summary to find wasted disk space using bash
Authored by: bluehz on Oct 12, '03 07:14:55AM

I believe the "P" option is relative to the version of du you have installed. The "P" option is not available for me in Jaguar running du version 4.1 installed via Fink.



[ Reply to This | # ]
Check a disk usage summary to find wasted disk space
Authored by: Nafai on Oct 10, '03 12:51:49PM
Oddly, I just did this yesterday, and looking for a good solution, I found What Size which is an awesome tool! It looks like a Finder window in column view, but it quickly calculates and sorts the files and directories by size, and marks the biggies in red, giving you a quick visual cue of where to go. It even shows Unix directories and file usage, so it's just as handy as this fabulous tip, but adds a GUI function to delete and immediately recalculate.

[ Reply to This | # ]
Or use "dusort" for *recursive* output
Authored by: cewatts on Oct 10, '03 11:27:21PM
Sure, you have to download and compile it, but you get nice, *RECURSIVE*, directory-by-directory size-sorted output.

http://www.unicom.com/sw/enh-du/

If you need help building it, send me a message and I'll upload a compiled version somewhere.

And if you do this even halfway-often, it's *so* much faster than going directory-by-directory.

Here's a sample:

cewatts@delerium cewatts $ du /usr/local | dusort
51376   /usr/local
36480       /usr/local/bin
11600       /usr/local/share
11600           /usr/local/share/ghostscript
11600               /usr/local/share/ghostscript/7.07
6552                    /usr/local/share/ghostscript/7.07/doc
4240                    /usr/local/share/ghostscript/7.07/lib
808                     /usr/local/share/ghostscript/7.07/examples
216                         /usr/local/share/ghostscript/7.07/examples/cjk
2376        /usr/local/lib
1400            /usr/local/lib/lynx_doc
368                 /usr/local/lib/lynx_doc/test
200                 /usr/local/lib/lynx_doc/samples
704             /usr/local/lib/lynx_help
272                 /usr/local/lib/lynx_help/keystrokes
736         /usr/local/man
536             /usr/local/man/man1
152             /usr/local/man/de
152                 /usr/local/man/de/man1
40              /usr/local/man/man8
96          /usr/local/etc
96              /usr/local/etc/mplayer
88          /usr/local/sbin
My address is cewatts@frontier.net.

[ Reply to This | # ]
Check a disk usage summary to find wasted disk space
Authored by: jmelloy on Oct 11, '03 05:07:58PM
du --max-depth=1 -kc | sort -nr works fairly well, too. It doesn't exclude the hidden . directories, which the other way will.

[ Reply to This | # ]
durep - useful tool
Authored by: the_shrubber on Oct 13, '03 04:34:58AM
durep - recursive, and gives you a nice visual representation (bar graphs) of where space is used most

[ Reply to This | # ]
durep - useful tool
Authored by: kissedsmiley on Aug 30, '07 06:02:30AM
url has changed, and here is a demo;
http://www.hibernaculum.net/durep/examples/durep.txt

[ /etc/X11 2.2M (7 files, 17 dirs) ]
1.5M [################### ] 65.43% xkb/
307.2K [#### ] 13.39% WindowMaker/
226.4K [## ] 9.87% app-defaults/
48.8K [ ] 2.13% fonts/
36.5K [ ] 1.59% ja/
30.8K [ ] 1.34% ro/
30.0K [ ] 1.31% fr/
29.7K [ ] 1.29% de/
24.0K [ ] 1.05% fluxbox/
17.0K [ ] 0.74% rgb.txt
13.8K [ ] 0.60% rstart/
11.1K [ ] 0.48% ja_JP.eucJP/
6.7K [ ] 0.29% Xsession.d/
3.3K [ ] 0.14% Xsession
3.2K [ ] 0.14% XF86Config-4
2.9K [ ] 0.12% xserver/
1021b [ ] 0.04% [COALESCED FILES]
385b [ ] 0.02% Xresources/
264b [ ] 0.01% xinit/
123b [ ] 0.01% cursors/
77b [ ] 0.00% xsm/



[ Reply to This | # ]