How to list packages by size using Aptitude

Biggest packages installed on my Ubuntu according to Aptitude
Biggest packages installed on my Ubuntu according to Aptitude

This is a query that I frequently have: how to list packages sorted by their size? I am especially interested in this about installed packages. There are other tools that can do this job, but I like to use Aptitude for this since I use it regularly anyway.

To list all available packages:

$ aptitude search ".*"

Aptitude understands the concept of the install size i.e., how much disk space the files of a package occupy after they are uncompressed and extracted from the package. So, sorting by this installsize is easy:

$ aptitude search ".*" --sort installsize

Note that this listing is in ascending order of size. So, the largest packages are listed at the end.

The problem with this listing is that Aptitude does not display the size, so we have no idea how big the install sizes are. To show that, we can tinker with the display format and get it to display the package name and install size:

$ aptitude search ".*" --display-format "%p %I" --sort installsize

Using the shorter versions of the options, this command becomes:

$ aptitude search ".*" -F "%p %I" -O installsize

Now, to list all installed packages:

$ aptitude search "~i"

Finally, to show the install size of only installed packages and sort by it, we just apply the options shown above:

$ aptitude search "~i" --display-format "%p %I" --sort installsize

Reference: Aptitude user’s manual (its man page is woefully short on details of its commands)

Tried with: Aptitude 0.6.8.2 and Ubuntu 14.04

One thought on “How to list packages by size using Aptitude”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s