If you’re running out of disk space and you want to quickly see what packages are using the most space on your hard drive, use the following command
dpkg-query
–-
show–-
showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10
That will sort the packages by size, putting the largest ones on the bottom. If you only want to see the top few, you can type
tail -n 10
Credit Goes here
My Output as follows
33.180 MB gimp-data
34.609 MB smbclient
36.891 MB libgl1-mesa-dri
39.023 MB evolution-common
43.797 MB openoffice.org-common
69.871 MB linux-headers-2.6.31-14
82.582 MB sun-java6-bin
86.039 MB linux-image-2.6.31-14-generic
109.215 MB openoffice.org-core
247.348 MB ubuntu-docs
tail -n 10
dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10
It gives me this error:
bash: syntax error near unexpected token `(‘
I also get the same error:
bash: syntax error near unexpected token `(’
Never mind that error happens if you cut and paste the command, the font of the quotes aren’t recognized by bash, either write it out by hand, or paste it and replace all the quotes before you execute
Hi.
It’s because the text printed on this page is beautified, Mainly double-dashes and quotes characters.
You have to replace the 2 double-dashes, the 4 quotes and the 2 double-quotes with normal ones (from your keyboard :p)
Regards.
same error as mrr
Hello there!
Is there anyway to keep only the 2.6.31-14 and remove the older versions of the kernel?? They seem to take quite a lot of space…
85.867 MB linux-image-2.6.31-11-generic
85.977 MB linux-image-2.6.31-12-generic
85.996 MB linux-image-2.6.31-13-generic
86.039 MB linux-image-2.6.31-14-generic
89.965 MB linux-image-2.6.27-7-generic
89.965 MB linux-image-2.6.27-9-generic
90.043 MB linux-image-2.6.27-11-generic
91.234 MB linux-image-2.6.28-11-generic
91.555 MB linux-image-2.6.28-15-generic
109.215 MB openoffice.org-core
247.348 MB ubuntu-docs
Thank you!
@starn
You can remove all of them except for the latest one (2.6.31-14 for you) and you wont have any problems
and remember to remove the headers as well
@starn
sorry forgot to tell you how, just open up synaptic package manager and remove all of them except for the latest one and make sure you remove the headers
@Richard Arkless
Thank you for the replies!!!
I tried to find through the synaptic manager the other version but I can only find as packages the 2.6.31-14.
I suspect that there is some type of cache with old packages that must be renewed/deleted…
It seams that there is a small mistake in the dpkg-query.
after the dpkg-query and its sort you are using “grep -v deinstall” to show only installed packages. But this information is missing in the output the dpkg-query generates.
(I recognized that there was also packages in the list i had removed a long time ago)
I think there has to be a “${Status}” in the –showformat of the query, because the grep needs this information to filter out the uninstalled packages.
this is my corrected query:
dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\t${Status}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10
you can verify the behavior better when changing the “tail -n 10” to a bigger value and compare the outputs of your code and my patched one.
did not work….even after replacing the quotes
@Gomel
That make absolutely sense to me, because now I get:
53.160 MB wine
55.301 MB sun-java6-jdk
65.582 MB sdcc-libraries
69.871 MB linux-headers-2.6.31-14
82.582 MB sun-java6-bin
83.633 MB virtualbox-3.0
86.039 MB linux-image-2.6.31-14-generic
88.543 MB eclipse-platform
109.215 MB openoffice.org-core
247.348 MB ubuntu-docs
So thank you very much for that!!
@harsh
Try it from that site (copy paste)
http://ubuntulife.wordpress.com/2009/11/13/tip-como-saber-que-paquete-de-software-esta-usando-mas-espacio/
Translated into Hebrew as part of the documentation resources of the Israeli Forum of Ubuntu
URL: http://ubuntu-il.com/forums/viewtopic.php?f=21&t=4298
wajig sizes
Synaptic can do this too: enable the “installed size” column, then click on the column label to sort by size.
I love bash.
Here is a simpler command that works:
dpkg-query -W -f=’${Package;-25}\t${Installed-Size}\n’ | sort -k2 -rn | grep -v deinstall | nawk ‘{ print $2 / 1024 “MB ” $1 }’ | head -10
73.355 MB openjdk-6-jre-headless
I don’t have any other Java packages installed so I thought I’d remove this one too, but… When I try to remove it (through apt-get) it says the package isn’t installed.
247.348 MB ubuntu-docs
wow :-O
this is the right command
dpkg-query –show –showformat=’${Package;-50}\t${Installed-Size}\n’ | sort -k 2 -n | grep -v deinstall | awk ‘{printf “%.3f MB \t %s\n”, $2/(1024), $1}’ | tail -n 10
If we “apt-get remove ubuntu-docs” will the whole system collapse or it’s just the help files???
Using ‘apt-cache show ubuntu-docs’:
Description: The Ubuntu Documentation Project
This package holds the official Ubuntu-specific documentation, maintained
by the Ubuntu Documentation Team. The documentation can be viewed using
Yelp, the GNOME help browser.
So just documentation. I wonder why it’s so huge?