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

I need to know why I'm almost out of space on the server,= and I don't know where most of the space is used.


10 Answers 10


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.

  • 15
    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. Nov 11, 2010 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 L
    Nov 13, 2010 at 1:36
  • 3
    what about du -cs * | sort -n for an overview of which directory is bigger?
    – lorenzog
    Jan 7, 2013 at 15:03
  • I prefer: du -ch | sort -nr | head -10
    – Sklavit
    Mar 12, 2018 at 11:32

My favorite tool for this task is ncdu.

ncdu example screen

  • 6
    Nice. It works pretty much the way I'd do it by hand (with du | sort), but with WAY less typing. Nov 12, 2010 at 4:19
  • 1
    This is much better. just install ncdu and type ncdu command on the directory you want to analyze, it works very fast.
    – Jamol
    Oct 7, 2018 at 13:20
  • never knew about this tool. this is perfect thank you
    – vampiire
    Dec 21, 2021 at 6:32

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.

  • cool, but I only have shell access on my VPS (low RAM)
    – aneuryzm
    Nov 11, 2010 at 22:21

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 /

Find biggest folders and their biggest subfolders successively

I parse through each folder level, to find the root of the problem, like this:

iteration 1

du -h --max-depth=1 -t 1G /Dir0/Dir1 | sort -n | tail -10

iteration 2

du -h --max-depth=1 -t 1G /Dir0/Dir1/biggestFolderInDir1 | sort -n | tail -10

-h: human readable sizes

-t 1G: only list directories bigger than 1G

sort -n: sort numerically (2G will be considered bigger than 1T)

tail -10: only list the last (biggest) 10 items

Manpages: du - sort - tail


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


Something like

sudo du / | sort -n

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

  • 2
    Define quick? In my experience this usually takes at least 5-10 minutes.
    – James L
    Nov 11, 2010 at 22:25

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


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.


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .