November 13, 2009 · Package Mgmt · Email This Post

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      openoffice.org-common
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      openoffice.org-core
247.348 MB      ubuntu-docs

Sponsored Link

Incoming search terms:

Related posts

24 Comments to “How To Check Which Software Package Is Using More Space”

  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

    [Reply]

  2. mrr says:

    It gives me this error:

    bash: syntax error near unexpected token `(‘

    [Reply]

  3. Chronic says:

    I also get the same error:

    bash: syntax error near unexpected token `(’

    [Reply]

  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

    [Reply]

  5. Renaud Merle says:

    Hi.

    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)

    Regards.

    [Reply]

  6. tenochslb says:

    same error as mrr

    [Reply]

  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 openoffice.org-core
    247.348 MB ubuntu-docs

    Thank you!

    [Reply]

  8. Richard Arkless says:

    @starn

    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

    [Reply]

  9. Richard Arkless says:

    @starn

    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

    [Reply]

  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…

    [Reply]

  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.

    [Reply]

  12. harsh says:

    did not work….even after replacing the quotes

    [Reply]

  13. stam says:

    @Gomel

    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 openoffice.org-core
    247.348 MB ubuntu-docs

    So thank you very much for that!!

    [Reply]

  14. Yaron Shahrabani says:

    Translated into Hebrew as part of the documentation resources of the Israeli Forum of Ubuntu
    URL: http://ubuntu-il.com/forums/viewtopic.php?f=21&t=4298

    [Reply]

  15. Mir says:

    wajig sizes

    [Reply]

  16. brian t says:

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

    [Reply]

  17. SammyBoy says:

    I love bash.

    [Reply]

  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

    [Reply]

  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.

    [Reply]

  20. karlzt says:

    247.348 MB ubuntu-docs

    wow :-O

    [Reply]

  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

    [Reply]

  22. stam says:

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

    [Reply]

  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?

    [Reply]

Leave a Reply