List Installed Packages by Size in Debian

In an embedded system, space is a very valuable commodity.  Sometimes, there are packages that are installed needlessly and they take up space.  A quick way to see the largest installed files in sorted order is:

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n


Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 5 Comments So Far

  • soomebob
    January 1st, 2012 at 11:24 am

    You have typo. Newline is \n instead of n in ${Package}n

  • [email protected]
    January 3rd, 2012 at 12:55 pm

    Thanks! It has been corrected.

  • castorp
    February 18th, 2012 at 5:44 am

    just setting up low end vps, so real helpful, many thanks

  • Jodes
    October 13th, 2016 at 9:46 am

    After removing packages using ‘sudo apt-get remove xxxx’ and ‘sudo autoremove’ the same packages are still listed? Yet ‘df -h’ shows that disk space has been freed. Why is the above command still showing uninstalled packages?

  • Derek Hildreth
    October 13th, 2016 at 9:58 am

    That is a very good question. The truth is, I don’t know why they’d be showing up still! Maybe there’s a caching issue happening with apt-get. What about `apt-get update` followed by the other commands? Does it still show the uninstalled packages?

Share your thoughts, leave a comment!