Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way in Unix to see the biggest directories on disk ?

I need to know why I'm almost done with the space on the server, and I dunno where most of the space is used..

thanks

share|improve this question
2  
possible duplicate of Find largest directories/files recursively –  Dennis Williamson Nov 11 '10 at 23:35

9 Answers 9

up vote 12 down vote accepted

Try: du --max-depth=7 /* | sort -n - it won't just tell you directories, and there will be duplicates, but it will list everything 7 levels deep and sort them by size order.

share|improve this answer
3  
7 levels all at once might be overwhelming. I would start with --max-depth=0 (or rather, use --summarize/-s), and then drill into the largest directories by hand. –  Steven Monday Nov 11 '10 at 23:31
    
Good point, just chose that number as that's how far I typically end up going before I find something useful. –  James Lawrie Nov 13 '10 at 1:36
    
what about du -cs * | sort -n for an overview of which directory is bigger? –  lorenzog Jan 7 '13 at 15:03

I suggest you to use baobab, which will give you a graphical overview of your disk usage. It can also be used for remote folder (through ssh, ftp,...) to scan the disk usage on a remote server for instance.

Edit: If you would like to investigate the disk usage directly on the server with your shell access and not remotely, and you would like a tool more convenient than du, you can also have a try with durep which will generate a report of the disk usage with bar graphs.

share|improve this answer
    
cool, but I only have shell access on my VPS (low RAM) –  Patrick Nov 11 '10 at 22:21

My favorite tool for this task is ncdu.

share|improve this answer
    
Nice. It works pretty much the way I'd do it by hand (with du | sort), but with WAY less typing. –  Steven Monday Nov 12 '10 at 4:19

I usually use something like this:

du -ch / | sort

You can apply a depth restriction using --max-depth= if you don't want to see past a certain level from your target, like so:

du -ch --max-depth=4 /
share|improve this answer

Try df & du -sh /. And recursively du -sh. Not the best solution though.

share|improve this answer

Something like

sudo du / | sort -n

Will give you a quick answer (last entries are largest files/directories)

share|improve this answer
    
Define quick? In my experience this usually takes at least 5-10 minutes. –  James Lawrie Nov 11 '10 at 22:25

# cd /; du -shb | sort -nr > /root/home/disk-space-report.txt

share|improve this answer

I always use syntax like

du -sm --max-depth=4 /path/i/want/to/drill | sort -nr | head -n 20.

max-depth and head parameters can vary, of course, but the above would list 20 biggest directories.

share|improve this answer

I'm regularly running du -dak > du-dak.out at the top of each file system. Then, I can get a graphical display with xdu < du-dak.out. This can be done remotely after transferring the du-dak.out file over the network should you only have text access.

http://sd.wareonearth.com/~phil/xdu/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.