Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Disk space on my root partition is running low, so I want to delete some applications from the system. How can I see which software packages use the most disk space? Is it possible to view that from aptitude?

I know about generic disk space analyzers like df or baobab, but I need solutions for installed applications.

share|improve this question
up vote 25 down vote accepted

Easiest is to run wajig large. The package should be an apt-install-away.

Here's two links for other ways of doing it:

Also remember that the installed size is just part of the space taken up by packages. The compressed version is probably still in the cache, and that takes up some space too. Don't recall what the command is to purge the cache off the top of my head.

share|improve this answer
The command to empty the package cache is apt-get clean. “clears out the local repository of retrieved package files” – man apt-get – manatwork Jun 10 '12 at 17:07

The easiest way (without installing extra packages) is:

dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n

which displays packages in size order, largest package last.

Unfortunately on at least some systems, this list includes packages that have been removed but not purged. All such packages can be purged by running:

dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge
share|improve this answer
Note that this apparently displays the size of all packages that have been installed on the system, regardless whether they are still installed (or have been uninstalled). – Calimo Apr 28 '15 at 6:43
@Calimo As far as I can tell when I run the query on my systems it is only showing installed packages, this is with dpkg version 1.16.16. (eg. this system has had multiple linux-image-* packages installed on it, and the dpkg-query only lists two tiny meta packages plus the two kernels that are actually installed currently, and no others) I am not sure why you might be seeing something different. – JosephH Apr 28 '15 at 12:04
I see something similar to what @Calimo reported. Because of lingering config files in /var/lib/dpkg/info, the package size of kernel components was listed. For example, 41219 linux-image-3.13.0-51-generic and 148465 linux-image-extra-3.13.0-51-generic even though this old kernel was removed quite a while ago by apt-get autoremove. – DK Bose Nov 20 '15 at 13:36
I see this too on my ubuntu box (dpkg 1.18.2). I'm not clear why it seems to happen on some systems but not others, however ` dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge` will purge all removed packages and fix it. – JosephH Apr 12 at 21:47

And of course there is aptitude awesomeness:

aptitude -F'%p %I' search texlive
texlive                                                       93.2 kB 
texlive-base                                                  44.1 MB 
texlive-bibtex-extra                                          52.4 MB 
texlive-binaries                                              13.0 MB 
texlive-binaries:amd64                                        13.5 MB 
texlive-doc-ar                                                92.2 kB 
texlive-doc-bg                                                92.2 kB 
texlive-doc-cs+sk                                             92.2 kB 
texlive-doc-de                                                92.2 kB 
texlive-doc-en                                                92.2 kB 
texlive-doc-es                                                92.2 kB 
texlive-doc-fi                                                92.2 kB 
texlive-doc-fr                                                92.2 kB 
texlive-doc-it                                                92.2 kB 
texlive-doc-ja                                                92.2 kB 
texlive-doc-ko                                                92.2 kB 
texlive-doc-mn                                                92.2 kB 
texlive-doc-nl                                                92.2 kB 
texlive-doc-pl                                                92.2 kB 
texlive-doc-pt                                                92.2 kB 
texlive-doc-rs                                                92.2 kB 

The key here is the -F which formats the output, the %p shows the package name and %I the installed size. You should use this instead to show only installed packages:

aptitude -F'%p %I' search '~i'

Or to sort by install size:

aptitude -O installsize -F'%p %I' search '~i'

It's also useful to change the default view in the interactive aptitude to include that information. To do that:

  • Click or navigate to Options->Preference
  • scroll to The display format for package views
  • Add %I in the value like %c%a%M%S %p %Z %t %I %v %V

You can also sort by installed-size by pressing Shift-S and enter installsize in the dialog box. Then, you can limit the view to only installed packages by pressing l (lowercase L) and enter ~i.


share|improve this answer
Not sure if there is a way to do it, but it'd be nice to always print size in kB, that'd make it much easier to sort or otherwise postprocess. – derobert Jan 22 '14 at 17:31
Nice, +1. Can you think of an easy way to show the total space freed? – terdon Jan 22 '14 at 17:35
@derobert was looking how I could control the white space in the output of aptitude, also, apparently there's no way to change the output of size. – Braiam Jan 22 '14 at 17:39
@Braiam yes, what is the total amount of space gained if I remove *texlive*? – terdon Jan 22 '14 at 17:43
@terdon mm... wouldn't aptitude -s remove '?and(texlive,~i)' be enough? Also, you can add a user-tag to certain package so you can manipulate them as whole (like the tasks). – Braiam Jan 22 '14 at 17:46

First of all, use a tool like baobab (sudo apt-get install baobab) to show you where that space is being used:

enter image description here

That will give you a nice graphical overview and help you narrow down what is taking up your space. You can also get this information on the command line using du:

$ sudo du -ch /

Pass this through sort (assuming GNU sort, whicih should be the case in Debian) to sort by directory size:

$ sudo du -ch / | sort -h

As a next step, you can see how much space a particular package is using with this command:

$ sudo apt-get --assume-no --purge remove "PACKAGE_NAME" | grep "be freed" | 
   awk '{print $4, $5}' 

On my system, for example, removing all texlive packages will free 1,502 MB:

$ sudo apt-get --assume-no --purge remove "texlive*" | grep "be freed" | 
   awk '{print $4, $5}' 
1,502 MB

Finally, you can get this information for all installed packages with this command:

$ for i in $(dpkg -l | awk '($1=="ii"){print $2}'); do  
    echo -e "$i\t"$(sudo apt-get --assume-no --purge remove "$i" | 
                    grep "be freed" | awk '{print $4, $5}'); 
share|improve this answer

You can use the wajig package, and the command

wajig large

The help explains what this does.

wajig large -h

usage: wajig large [-h]

List size of all large (>10MB) installed packages

See also the project page.

share|improve this answer

In case you don't want to install wajig. I imagine everybody has debian-goodies installed:

dpigs              - Show which installed packages occupy the most space
share|improve this answer
wajig requires python 3 which is another 40mb. debian-goodies requires python 2.6+ so is 700kb additional. This or JosephH's answer are the best! – Tim O'Brien Apr 9 '15 at 19:42

While this is a nice collection of tools, to which I'd add the KDE / QT Filelight, which is similar to other gui disk space usage tools, it's not the literal answer to the topic title.

If you take the question of this thread literally, that is, what are the largest packages in your system, as a rule, they are:

The libreoffice suite of packages, which isn't a single package, but it's really big.

The linux kernel and associated header packages comes I think second, and if you have multiple kernels installed, which most systems tend to have, each one is around I think 135 mB disk space, roughly, gets bigger every year, but it's about that big. If you use non free video drivers there would be the associated driver packages/files as well. Note that as with libreoffice, each kernel actually can actually be made up of 2 or 3 packages, the image, header, and driver packages, so a literal per package size count isn't actually that accurate except to get a crude sense.

After those, there aren't a huge number of massive packages in Debian's package pool that I'm aware of.

I find that once the root partition starts getting big enough to where you start wondering how to get rid of packages to shrink it, it's generally time to move/resize to a bigger root partition.

apt-get clean of course is the first thing to run, to get rid of all the cached .deb files, but once you remove that, and all but say 2 kernels, if you're still stuck with not enough room, it's more practical to increase the partition size since the cleanups etc just are red flags you are running close to out of root partition space, which can be a real problem if apt doesn't have enough room in /var to actually download and extract packages for an upgrade. Cleaning out by purge actions leftover config files from removed packages won't do you any good at all in terms of regaining disk space since they are tiny, but it is nice to do now and then just to clean up cruft, but it shouldn't be mistaken for actually regaining any meaningful disk space.

apt-get auto-remove isn't bad either, but be aware that it's sometimes wrong about the package being removed, so you want to check that list carefully before you let apt remove the stuff. Technically it's better to purge that list, that way you get rid of the config files as well at the same time, remove or auto-remove will I believe leave them in place.

share|improve this answer

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.