How do I find the largest top files and directories on a Linux or Unix-like operating systems?

Sometimes it is necessary to know what file(s) or directories are eating up all your disk space. Further, it may be required to find out it at the particular directory location on filesystem such as /tmp/ or /var/ or /home/. This guide will help you to use Unix and Linux command for finding the largest or biggest the files or directories on the filesystem.

How to find out top 10 files and directories on Linux or Unix

There is no simple command available to find out the largest files/directories on a Linux/UNIX/BSD filesystem. However, combination of following three commands (using pipes) you can easily find out list of largest files:

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux and Unix-like OS
Est. reading time 3 minutes

Steps to find Largest Directories in Linux

  1. du command : Estimate file space usage.
  2. sort command : Sort lines of text files or given input data.
  3. head command : Output the first part of files i.e. to display first 10 largest file.
  4. find command : Search file.

How to find out top Directories and files in Linux

Type the following command at the shell prompt to find out top 10 largest file/directories:
# du -a /var | sort -n -r | head -n 10
Sample outputs:

1008372 /var
313236  /var/www
253964  /var/log
192544  /var/lib
152628  /var/spool
152508  /var/spool/squid
136524  /var/spool/squid/00
95736   /var/log/mrtg.log
74688   /var/log/squid
62544   /var/cache

If you want more human readable output try (works with GNU/Linux du version/user only):
$ cd /path/to/some/where
$ du -hsx * | sort -rh | head -10
$ du -hsx -- * | sort -rh | head -10


  • du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
  • du command -s option : show only a total for each argument (summary).
  • du command -x option : skip directories on different file systems.
  • sort command -r option : reverse the result of comparisons.
  • sort command -h option : compare human readable numbers. This is GNU sort specific option only.
  • head command -10 OR -n 10 option : show the first 10 lines.

The above command will only work of GNU/sort is installed. Other Unix like operating system should use the following version (see comments below):

for i in G M K
  du -ah | grep [0-9]$i | sort -nr -k 1
done | head -n 11

Sample outputs:

179M	.
84M	./uploads
57M	./images
51M	./images/faq
49M	./images/faq/2013
48M	./uploads/cms
37M	./videos/faq/2013/12
37M	./videos/faq/2013
37M	./videos/faq
37M	./videos
36M	./uploads/faq

Find the largest file in a directory and its subdirectories using the find command

Type the following GNU/find command:

## Warning: only works with GNU find ##
find /path/to/dir/ -printf '%s %p\n'| sort -nr | head -10
find . -printf '%s %p\n'| sort -nr | head -10

Sample outputs:

5700875 ./images/faq/2013/11/iftop-outputs.gif
5459671 ./videos/faq/2013/12/glances/glances.webm
5091119 ./videos/faq/2013/12/glances/glances.ogv
4706278 ./images/faq/2013/09/
3911341 ./videos/faq/2013/12/vim-exit/vim-exit.ogv
3640181 ./videos/faq/2013/12/python-subprocess/python-subprocess.webm
3571712 ./images/faq/2013/12/glances-demo-large.gif
3222684 ./videos/faq/2013/12/vim-exit/vim-exit.mp4
3198164 ./videos/faq/2013/12/python-subprocess/python-subprocess.ogv
3056537 ./images/faq/2013/08/debian-as-parent-distribution.png.bak

You can skip directories and only display files, type:

## How to Find Out Top Directories and Files (Disk Space) in Linux Using Find ##
find /path/to/search/ -type f -printf '%s %p\n'| sort -nr | head -10


## another option ##
find /path/to/search/ -type f -iname "*.mp4" -printf '%s %p\n'| sort -nr | head -10

Hunt down disk space hogs with ducks

Let us find out top directories and files using disk space in Linux or Unix with help of the following bash shell alias:

## shell alias ##  
alias ducks='du -cks * | sort -rn | head'
## deal with special files names ##
alias ducks='du -cks -- * | sort -rn | head'

Run it as follows to get top 10 files/dirs eating your disk space:
$ ducks
Sample outputs:

Fig.01 Finding the largest files/directories on a Linux or Unix-like system

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 64 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
64 comments… add one
  • Anonymous Apr 12, 2006 @ 11:13

    Great, but what if I only want the largest files and not the directories?

  • 🐧 nixcraft Apr 12, 2006 @ 18:26

    To find out largest file only use command ls as follows in current directory:
    ls -lSh . | head -5
    -rw-r–r– 1 vivek vivek 267M 2004-08-04 15:37 WindowsXP-KB835935-SP2-ENU.exe
    -rw-r–r– 1 vivek vivek 96M 2005-12-30 14:03 VMware-workstation-5.5.1-19175.tar.gz
    ls -lSh /bin | head -5
    You can also use find command but not du:
    find /var -type f -ls | sort -k 7 -r -n | head -10

    Hope this helps

  • 🐧 nixcraft Apr 12, 2006 @ 18:35

    And yes to find the smallest files use command:
    ls -lSr /var

    Or use find command with -size flag.
    find / -type f -size +20000k -exec ls -lh {} ; | awk ‘{ print $8 “: ” $5 }’

    Read man page of find for more info.

    • Spechal Jun 22, 2011 @ 17:47

      “find / -type f -size +20000k -exec ls -lh {} ; | awk ‘{ print $8 “: ” $5 }’”

      needs to have the exec altered

      find / -type f -size +20000k -exec ls -lh {} \; | awk ‘{ print $8 “: ” $5 }’

      Also, I find this output easier to read

      find . -type f -size +20000k -exec ls -lh {} \; | awk ‘{print $5″: “$8}’

  • john Jan 19, 2007 @ 19:43

    How do I can list all the files in several directories and at the end write the totat of all the files and directories.I’m using the du command as fallow:
    du -sh /public/base/sites/F*/*20070115*

    this command give me the size of all the files but not the global total.

    can somebody help me. please write me.

  • Joe Jan 23, 2007 @ 0:49

    “If you want more human readable output try:

    # du -ha /var | sort -n -r | head -n 10”

    Im pretty sure that this will put 999kb above 1gb so I don’t think that this works.

  • ChrisMM Apr 17, 2007 @ 7:26

    This does not work.

    # du -ha /var | sort -n -r | head -n 10″

    as Joe says this ignores files over 1gb

  • Dreyser May 27, 2007 @ 23:32

    You could try this, gives a human readable output in MB

    find . -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s\n", size,$2);}' | head

  • Benjamin Schmidt Sep 26, 2007 @ 18:32

    Human readable version:

    for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done

  • RudyD May 23, 2008 @ 16:06

    If you set du to human readable I think it will not sort the way you really want.

    For the above problems. I would like to find a way to list only the last level directories’ sizes.

    (I want to filter somehow this:

    I just want to see the lasts of the tree!)



  • yanokwa Jun 11, 2008 @ 15:22

    this is what i use.

    for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11

    • Srinivas Oct 25, 2013 @ 16:56

      Worked like charm

    • sandesh Oct 20, 2020 @ 15:35

      Thank you

  • rschu68 Sep 19, 2008 @ 13:46

    find . -type f -print0| xargs -0 ls -s | sort -rn | awk ‘{size=$1/1024; printf(“%dMb %s\n”, size,$2);}’ | head

    ! -print0 for filenames with spaces …
    (and xargs -0 combined)

  • Winfan Apr 14, 2009 @ 0:04

    No wonder windows rule

    • Mr-Yellow Jul 26, 2011 @ 0:54

      Yeah you just go ahead and wait the 3 hours this search would take on Windows.

      • Nick Nov 30, 2011 @ 13:56

        How about the 3 hours it takes to read through a bunch of unexplained programming nonsense. I swear half of the time all Linux guys do is insult other users….Example, the first listing is great as it begins to explain what the flags do, but I have no idea were to put some of them, pipes are not explained…ect

        • BigB Jun 24, 2015 @ 15:03

          This is why Winblows users should not try and use Linux, they are very unintelligent and lack the ability to look up simple things.

    • Robert Sullivan Sep 28, 2015 @ 16:30

      Fast forwarda few years, Linux won, bro :)

      “Late last week, hell had apparently frozen over with the news that Microsoft had developed a Linux distribution of its own. The work was done as part of the company’s Azure cloud platform, which uses Linux-based network switches as part of its software-defined networking infrastructure.” — SOURCE HERE.

  • beez Jun 19, 2009 @ 22:31

    Winfan, I read this page wondering how to do these things in Windows — can you post instructions? Thanks!

    • Dave Jan 18, 2011 @ 17:56

      This may vary depending on the version of Windows you’re using, but the basic procedure is: open the find/search window, go to the advanced options, and there will be an option there to enter in a size parameter. Simple.

      In XP, press F3 or go Start->Search. Choose “All files and folders”, then “More advanced options”, then “What size is it?”, then specify a size.

      • SamTzu Aug 6, 2013 @ 16:35

        I believe beez was being sarcastic towards Winfan as was his right after Winfans brainless comment. Most Linux distro GUI’s come with search function just like Windows GUI.

        Now just try to do the search on command line on Windows (server)…


  • sridevika lover Jun 22, 2009 @ 18:38

    thanks !!!!!!!!!!!!!!!!!

  • webmaster@@@@@@@@@@@ Jun 22, 2009 @ 18:39

    great job !!!!!!!!!!!

  • notafan Aug 21, 2009 @ 21:54

    @winfan… how do you do this in windows? you don’t :P

    • Jayman Sep 12, 2011 @ 20:31

      c:\>dir /S /O-S | more

      The simple dir /S command from c:\ will give you all files and directories from c:\ all the way through the drive and will sort from largest to smallest running through each directory. You can filter using /A if you’d like to restrict by hidden, system, archive files, read only files etc. and passing the output to another windows command if you need to further restrict or search in the files for something like “show me all the files on my hard drive over 6MB that contain the word ‘log’ from largest to smallest.”

      /O will Specify the sort order for the files with the S after it sorting by file size (smallest first) putting the – in front of the S reverses the order.

      | more – you’re a unix dude, you should know what this means…

      But if someone is doing some cleanup through their harddrive, this is the simple command I’d start with.

      Just a note about the cockyness or us Unix admins (as I happen to be one now)
      Not everyone that uses windows started using it with a mouse kid!!! Also not everyone who prefers windows is not cross-platform… We were running 64 bit clustered NT boxes on RISC processors at Digital Equipment Corporation with failover and failback in 1996 brother. Don’t believe me? Find a really old copy of Windows NT ver 3.51 open it and you’ll see two folders NT and Alpha.

      The Department of Veterans Affairs had no problems with ever needing to reboot a “lousy unreliable windows box” because the Intel platform itself was the problem, not windows. We ran Alpha on 64 bit RISC processors and it was just as reliable as any Unix box or Mainframe we had. I had a Jensen Alpha running an exchange server for 5 years, and we only rebooted it every 6 months for giggles…

      Windows machines are made to be used by the masses which means more dumbasses can kinda run one. A good Admin is a good Admin, no matter what platform. Be nice and be helpful or don’t post.

  • Tihamer Jan 20, 2010 @ 18:08

    Notafan wrote:
    @winfan… how do you do this in windows? you don’t :P

    Well, actually, there *is* cygwin (unix commands for Windows systems)

  • Keith White Apr 7, 2010 @ 10:44

    I find the following works rather well…

    du -xak . | sort -n | awk '{size=$1/1024; path=""; for (i=2; i 50) { printf("%dMb %s\n", size,path); } }'

    It lists all files or directories bigger than 50MB (just change size>50 to alter that) in the current directory (change the “.” to a directory path to specify another one) in a friendly, human-readable way and happily plays with spaces (I used it on an NTFS mount in fact).

    • Brian Mar 10, 2011 @ 3:00

      I get a syntax error when coptying and pasting this command

      • Thomas Dec 21, 2011 @ 11:19

        Same here…

  • Rafiq Feb 18, 2011 @ 20:51

    I found this one the simplest one.
    ls -lSh . | head -5

  • Satish Jun 13, 2011 @ 22:22

    I have learnt a lot from your posts

    thanks alot and keep it up.

  • aaa Oct 4, 2011 @ 14:44

    ls -lR | sort -nr +4 -5 | head

  • Nalinda Dec 14, 2011 @ 23:29

    Thanks heaps for this. It saved me lot of time.

  • Steve Aug 22, 2012 @ 13:14

    The easiest way would be
    ls -lSh | head -n 10

  • tobeportable Mar 10, 2013 @ 12:06

    install `ncdu`

  • Avi Apr 18, 2013 @ 14:50

    I second that! Try NCDU, it’s command-line and gives you interactive folder listings.

  • remke Apr 18, 2013 @ 19:43

    -> dispus2.7 (google)

    With kind regards,

  • Azad Jun 4, 2013 @ 11:56

    How to go at last line at a big file directly by using the unix command. cud u plz assist me for the same @

    • Azheruddin Sep 17, 2014 @ 4:56

      By using vi editor edit the file
      and press shift + g you will move to last line of the file.

      now to add or insert you need to press i i.e insert mode and add data then to save
      press wq!
      the file will be saved and you will quit from file .

  • karthik Jul 13, 2013 @ 0:35

    How can i find the largest file size in centos ..
    and also through dates and all the details of the file.


  • Anjana.S Jul 21, 2013 @ 7:55

    how can i open a human readable file from my current directory?

  • shirish Oct 13, 2013 @ 4:30

    hows this !!!
    ##top 20 ##
    # find /var -ls 2>/dev/null | sort -nrk 7 | awk '{print $NF}' | xargs ls -lSh | head -20

  • Christian Benesch Nov 8, 2013 @ 13:00

    The following is working and sorting properly by Gigabyte, Megabytes and Kilobytes:

    for i in G M K; do du -ah | grep ^[0-9\.]*$i | sort -nr -k 1; done | head -n 110

    Basically it makes sure to grep from the *beginning* of the line and to include the possible decimal points. In your version it would have stumbled over filenames beginning with numbers and a ‘G’ for instance.

    • Dharmesh Oct 29, 2015 @ 15:31

      thats it, neat!

  • Suraj Nov 15, 2013 @ 15:56

    I need to display only the name of the file with maximum size in home directory…please help..

  • Silverback Dec 3, 2013 @ 20:06
    find / -xdev -size +2048 -ls  

    List all files larger than 1 mb. Displays

    1632043 2656 -rw-r-----   1 root     adm       2715648 Dec  3 13:51 /var/log/mail.log

    Datasource: IBM AIX Version 3 Commands Reference Volume 1
    A bit dated but it works just fine on Debian 7.

  • Deepak Mar 13, 2014 @ 10:33

    How to find the largest top 10 files with the file modified date?

  • Mohammed Zafar Jan 5, 2015 @ 6:08

    I want to check which folder take a more size because i want clean it

    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda3              15G   12G  1.9G  87% /
  • Christopher Ranschaert Oct 29, 2015 @ 16:48

    I have the following:

    alias dush='du -sch .[!.]* * | sort -h'

    This adds the .hidden .directories as well (skipping parent .. directory), and sorts in human-readable format (GNU version of sort)

  • Dan Stromberg Dec 8, 2015 @ 22:45

    For the 10 largest files in an entire filesystem (n = 10):
    find /mount/point -xdev -type f -print0 | xargs -0 du -sk | sort -n | head -10

    Or a faster way for a truly huge filesystem and small n:
    find /mount/point -xdev -type f -print0 | xargs -0 du -sk | highest -n 10 --use-bisect

    …where highest can be found here.

    highest is faster because, although GNU sort is quite impressive, it’s still O(nlogn), while highest is O(n).


  • arabek Dec 11, 2015 @ 9:15

    Or you could simply use the ncdu command, which has a nice graphical interface to it, and even allows you to interactively delete stuff when not needed.

  • Duck Hunter Feb 8, 2016 @ 9:54

    Thanks! Duck hunting is awesome! This saved me and my server real quickly!

  • Roger Feb 28, 2016 @ 1:44

    thank you so much, helped me a lot!

  • khadeer May 9, 2016 @ 12:50

    how to find largest file in a directory

  • Ur5u5 May 26, 2016 @ 5:37

    Very useful. Thanks a lot.

  • They're takin' our jerbs! Jul 7, 2016 @ 21:53

    Why doesn’t someone post a simple graphical tool for the casual user who doesn’t get an erection typing commands at a shell prompt. For example:

  • Slava Fomin Jul 15, 2016 @ 10:28

    Please look at the following command to see all files larger than 20MiB
    find / -size +20M -ls
    List files between 100MiB and 120MiB
    find / -size +100M -size -120M -ls

    “ncdu” is very useful.

  • Jamiel Sharief Oct 21, 2016 @ 7:40

    Many thanks, it was exactly what I was looking for.

  • Govardan Nayaki Jan 10, 2017 @ 18:38

    How can I find top users consuming space in a directory ?

  • Vlad Jan 13, 2017 @ 1:59

    Thank you very much for the effort! This was a very useful topic.

  • batobalani Jan 14, 2017 @ 4:56

    search directories with above 90% disk space usage

    df -lh | awk '/[9][0-9]%/'

  • Dnyaneshwar Jan 19, 2017 @ 5:50

    The best way is to use ls, sorted by size:
    ls -S
    To get the biggest one, use head:
    ls -S | head -1
    If u want max 2 files just change -1 to -2 and so on
    ls -S | head -2

  • Yama Fajra Mar 26, 2021 @ 10:31

    Wanted to find out top directories and files {Disk Space} in Linux and this page is what exactly I needed. thank you very much kind sir.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum