📦 How to list installed packages by size on Ubuntu/Debian – IT is good

📦 How to list installed packages by size on Ubuntu/Debian

In this guide, we’ll walk through the steps to list installed packages by size on Ubuntu/Debian Linux systems.

This can be important when doing a space audit and trying to find packages that are taking up a lot of space on your system.

Ubuntu/Debian dpkg-query and dpkg package manager provide some command line options that can be used for this task with some Linux regex tools like awk, sed, sort, tr

List Installed Package Sizes with Wajig

Wajig is a lightweight command line administrator for Debian/Ubuntu packages.

We can use this program to get a list of package sizes.

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
OutputPackage 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 above result, you can see that the package that takes up the most space on my Ubuntu server is linux-image-extra-3.13.0-143-generic with a size of 150MB.

Listing the sizes of installed packages using the dpkg-query command

You can also use the dpkg-query command to get a list of installed packages filtered by size.

dpkg-query is a tool used to display information about packages listed in the dpkg database.

You must use the -Wf option and pipe the output to the sort command to get the output sorted in order.

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 10
Output23508 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 that of the wajig command.

The last file in the list is the largest.

List installed package sizes using dpigs

Dpigs is a Debian tool that is used to show which installed packages are taking up the most space on the system.

dpigs sorts installed packages by size and lists the largest ones, showing 10 packages by default.

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

apt install debian-goodies

Now, to list the size of installed packages, 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

How to show installed package size with /var/lib/dpkg/status and awk

You can also use awk to read /var/lib/dpkg/status and filter it to get the size of each package installed on your system.

To do this, use the command:

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

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

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 the packet sizes in ascending order, from smallest to largest.

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


In this guide, we learned how to list installed packages by size in Ubuntu.

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

Ubuntu,Debian,Linux,Linux Mint.,

#list #installed #packages #size #UbuntuDebian #good

Leave a Comment

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