How To Check Which Software Package Is Using More Space

If you’re running out of disk space and you want to quickly see what packages are using the most space on your hard drive, use the following command

dpkg-query –-show –-showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10

That will sort the packages by size, putting the largest ones on the bottom. If you only want to see the top few, you can type

tail -n 10

Credit Goes here

My Output as follows

33.180 MB      gimp-data
34.609 MB      smbclient
36.891 MB      libgl1-mesa-dri
39.023 MB      evolution-common
43.797 MB
69.871 MB      linux-headers-2.6.31-14
82.582 MB      sun-java6-bin
86.039 MB      linux-image-2.6.31-14-generic
109.215 MB
247.348 MB      ubuntu-docs

Sponsored Link

You may also like...

24 Responses

  1. Moh says:

    tail -n 10

    dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10

  2. mrr says:

    It gives me this error:

    bash: syntax error near unexpected token `(‘

  3. Chronic says:

    I also get the same error:

    bash: syntax error near unexpected token `(’

  4. Chronic says:

    Never mind that error happens if you cut and paste the command, the font of the quotes aren’t recognized by bash, either write it out by hand, or paste it and replace all the quotes before you execute

  5. Renaud Merle says:


    It’s because the text printed on this page is beautified, Mainly double-dashes and quotes characters.

    You have to replace the 2 double-dashes, the 4 quotes and the 2 double-quotes with normal ones (from your keyboard :p)


  6. tenochslb says:

    same error as mrr

  7. stam says:

    Hello there!

    Is there anyway to keep only the 2.6.31-14 and remove the older versions of the kernel?? They seem to take quite a lot of space…

    85.867 MB linux-image-2.6.31-11-generic
    85.977 MB linux-image-2.6.31-12-generic
    85.996 MB linux-image-2.6.31-13-generic
    86.039 MB linux-image-2.6.31-14-generic
    89.965 MB linux-image-2.6.27-7-generic
    89.965 MB linux-image-2.6.27-9-generic
    90.043 MB linux-image-2.6.27-11-generic
    91.234 MB linux-image-2.6.28-11-generic
    91.555 MB linux-image-2.6.28-15-generic
    109.215 MB
    247.348 MB ubuntu-docs

    Thank you!

  8. Richard Arkless says:


    You can remove all of them except for the latest one (2.6.31-14 for you) and you wont have any problems

    and remember to remove the headers as well

  9. Richard Arkless says:


    sorry forgot to tell you how, just open up synaptic package manager and remove all of them except for the latest one and make sure you remove the headers

  10. stam says:

    @Richard Arkless

    Thank you for the replies!!!

    I tried to find through the synaptic manager the other version but I can only find as packages the 2.6.31-14.

    I suspect that there is some type of cache with old packages that must be renewed/deleted…

  11. Gomel says:

    It seams that there is a small mistake in the dpkg-query.

    after the dpkg-query and its sort you are using “grep -v deinstall” to show only installed packages. But this information is missing in the output the dpkg-query generates.

    (I recognized that there was also packages in the list i had removed a long time ago)

    I think there has to be a “${Status}” in the –showformat of the query, because the grep needs this information to filter out the uninstalled packages.

    this is my corrected query:
    dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\t${Status}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10

    you can verify the behavior better when changing the “tail -n 10” to a bigger value and compare the outputs of your code and my patched one.

  12. harsh says:

    did not work….even after replacing the quotes

  13. stam says:


    That make absolutely sense to me, because now I get:

    53.160 MB wine
    55.301 MB sun-java6-jdk
    65.582 MB sdcc-libraries
    69.871 MB linux-headers-2.6.31-14
    82.582 MB sun-java6-bin
    83.633 MB virtualbox-3.0
    86.039 MB linux-image-2.6.31-14-generic
    88.543 MB eclipse-platform
    109.215 MB
    247.348 MB ubuntu-docs

    So thank you very much for that!!

  14. Yaron Shahrabani says:

    Translated into Hebrew as part of the documentation resources of the Israeli Forum of Ubuntu

  15. Mir says:

    wajig sizes

  16. brian t says:

    Synaptic can do this too: enable the “installed size” column, then click on the column label to sort by size.

  17. SammyBoy says:

    I love bash.

  18. Tom says:

    Here is a simpler command that works:
    dpkg-query -W -f=’${Package;-25}\t${Installed-Size}\n’ | sort -k2 -rn | grep -v deinstall | nawk ‘{ print $2 / 1024 “MB ” $1 }’ | head -10

  19. DaVince says:

    73.355 MB openjdk-6-jre-headless

    I don’t have any other Java packages installed so I thought I’d remove this one too, but… When I try to remove it (through apt-get) it says the package isn’t installed.

  20. karlzt says:

    247.348 MB ubuntu-docs

    wow :-O

  21. karlzt says:

    this is the right command

    dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10

  22. stam says:

    If we “apt-get remove ubuntu-docs” will the whole system collapse or it’s just the help files???

  23. DaVince says:

    Using ‘apt-cache show ubuntu-docs’:

    Description: The Ubuntu Documentation Project
    This package holds the official Ubuntu-specific documentation, maintained
    by the Ubuntu Documentation Team. The documentation can be viewed using
    Yelp, the GNOME help browser.

    So just documentation. I wonder why it’s so huge?

Leave a Reply

Your email address will not be published. Required fields are marked *