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