Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to look at some statistics on the size of packages in the Ubuntu repositories, and I'm hoping to sort my searches of packages in the repositories by file size. Is there a command that will let me look at file sizes of packages in the repositories/cache, sort them by file size, etc? `apt-cache stats' doesn't provide all the information I'd like.

I'm interested in only the official repositories at the moment, and I'm interested in sorting all packages in the repositories, not simply the ones I have installed.

share|improve this question
If the solution I proposed works for you, could you please accept this answer? Thanks! – Marcin Kaminski Nov 30 '12 at 1:25
@MartinOrda Patience... My office computer does not run Ubuntu, and I won't be back in my flat and able to test your answer for a while. If it works, I will accept it once I have a chance to test it. – Ricardo Altamirano Nov 30 '12 at 1:30
Of course, that's why I asked for it on the provision that it works for you :) I'm not in a rush. – Marcin Kaminski Nov 30 '12 at 1:47
@MartinOrda Worked perfectly! – Ricardo Altamirano Nov 30 '12 at 4:45
up vote 2 down vote accepted

That should work:

apt-cache -f dumpavail | \
egrep '^Package:|^Size:' | \
sed -e 's,Size: ,,' -e 's,Package: ,\n,' | \
awk '{RS=""; FS="\n"} {print $1, $2}' | \
sort -k2 -n

I'm not proud of it but that was done in a bit of a hurry :)

share|improve this answer
Glad to hear! Thank you. – Marcin Kaminski Nov 30 '12 at 8:48

for installed packages you can either use a oneliner:

dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n

or third-party tools like wajig:

sudo aptitude install wajig
wajig large

this will give output like

libreoffice-core                   117,412      installed
google-chrome-stable               136,744      installed
linux-image-3.2.0-23-generic       145,113      installed
linux-image-3.2.0-33-generic       145,872      installed
nvidia-current                     179,133      installed

for searches something like this might help:

aptitude search vnc -F "%p %I"

This gives output like:

$ aptitude search xvnc -F "%p %I"
linuxvnc                71.7 kB 
linuxvnc:i386           66.6 kB 
xvnc4viewer             430 kB  
xvnc4viewer:i386                400 kB 

the %I shows the "installed" size of the archive. Now you have the ability to use sort to sort the results as you wish.

share|improve this answer
Thank you for the tips, but I'm interested in any packages in the repositories, not just the ones I have installed. – Ricardo Altamirano Nov 29 '12 at 13:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.