How to List Installed Packages by Size on Ubuntu

Written by: Linuxopsys   |   Last updated: September 3, 2022

In this tutorial, we learn through the steps to list installed packages by size on Ubuntu/Debian Linux systems. This can be important when doing space audits and trying to find packages using occupying large space on your system.

The Ubuntu / Debian dpkg-query and dpkg package manager provide some command line options which can be utilized for this task, with the help of some Linux regex tools like awk, sed, sort, tr etc.

List Installed Package Size using Wajig

Wajig is a simplified command line administrator for Debian / Ubuntu packages. We can use this program to list package size.

This  tool can be installed using the commands:

sudo apt install wajig

To list the largest installed packages in descending order, use the command:

wajig large
Package Size (KB) Status
libc6 10,508 installed
grub-common 11,484 installed
linux-headers-3.13.0-32-generic 12,999 installed
linux-headers-3.13.0-143-generic 13,216 installed
iso-codes 15,207 installed
perl-modules 16,134 installed
perl 17,320 installed
vim-runtime 25,186 installed
linux-image-3.13.0-32-generic 41,029 installed
linux-image-3.13.0-143-generic 43,054 installed
linux-headers-3.13.0-32 61,797 installed
linux-headers-3.13.0-143 62,064 installed
linux-firmware 124,150 installed
linux-image-extra-3.13.0-32-generic 148,283 installed
linux-image-extra-3.13.0-143-generic 150,240 installed

From the output above, the package which utilizes the largest space on my Ubuntu server is linux-image-extra-3.13.0-143-generic which is 150Mb in size.

List Installed Package Size using dpkg-query

You can also use the dpkg-query command to list installed package filtered by size.  The dpkg-query is a tool used to show information about packages listed in the dpkg database. You have to use the options -Wf and pipe the output to sort command to get the output sorted in order.

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10
23508 git
26870 vim-runtime
30094 libicu55
32502 cassandra
65367 linux-image-4.4.0-87-generic
68901 linux-headers-4.4.0-87
75176 snapd
97190 openjdk-8-jre-headless
148663 linux-image-extra-4.4.0-87-generic
207968 linux-firmware

You should notice that this output is similar to the one from the wajig command. The last file listed is the largest.

List Installed Package Size using dpigs

Dpigs is a Debian tool that's used to show which installed packages occupy the most space on the system. dpigs sort the installed packages by size and output the largest ones, the default number of packages displayed is 10. 

This tool is not installed by default, installing it on Ubuntu / Debian system using the command.

apt install debian-goodies

Now to list the installed packages size, type

150240 linux-image-extra-3.13.0-143-generic
148283 linux-image-extra-3.13.0-32-generic
124150 linux-firmware
93841 libboost1.54-dev
62064 linux-headers-3.13.0-143
61797 linux-headers-3.13.0-32
54539 openjdk-7-jre-headless
43054 linux-image-3.13.0-143-generic
41029 linux-image-3.13.0-32-generic
39210 python-neutron

Show Installed Package Size using /var/lib/dpkg/status and awk

You can also use awk to read data from /var/lib/dpkg/status and filter it to get the size of each package installed on your system. For this, use the command below.

awk '{if ($1 ~ /Package/) p = $2; if ($1 ~ /Installed/) printf("%9d %s\n", $2, p)}' /var/lib/dpkg/status
List package size installed ubuntu

You can filter the output further by piping it to the sort and tail|head command.

awk '{if ($1 ~ /Package/) p = $2; if ($1 ~ /Installed/) printf("%9d %s\n", $2, p)}' /var/lib/dpkg/status | sort -n | tail

The above command will show you package sizes in ascending order - From smallest to largest.

There are other commands you can use but all do the same thing. This should give you enough information to get started. You can write your own functions/aliases or bash scripts using the same commands for quick execution and reference.


In this tutorial, we learned how to list installed packages by size on Ubuntu.

Thanks for reading, please leave your feedback and suggestions in the below comment section.



Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment