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.


9 Answers 9


The easiest way (without installing extra packages) is:

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

which displays packages in estimated size order, in kilobytes, 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

Or if you don't want to purge uninstalled packages you can use this variant to filter out the packages which aren't in the 'installed' state from the list:

dpkg-query -Wf '${db:Status-Status} ${Installed-Size}\t${Package}\n' | sed -ne 's/^installed //p'|sort -n
  • 4
    FWIW, if you want the largest packages first, use sort -nr instead of sort -n. Commented Apr 10, 2020 at 12:14
  • 1
    @AndreHolzner I would recommend sort -nr | head Commented Jun 29, 2023 at 19:58

The easiest way 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. You can remove those with apt-get clean.

  • 5
    The command to empty the package cache is apt-get clean. “clears out the local repository of retrieved package files” – man apt-get
    – manatwork
    Commented Jun 10, 2012 at 17:07
  • What does "config-files" vs "installed" mean in wajig output? Their documentation doesn't quite explain this. Commented Jun 19, 2020 at 7:38
  • @Fizz I suspect "config-files" means that the package has been uninstalled, but has not been purged (apt-get purge) so the config files are still there in case the package is reinstalled at a later time.
    – mxbi
    Commented Mar 9, 2021 at 17:32

Since you want to "see which [installed] software packages use the most disk space[,] from aptitude" ... of course you can use aptitude! via either its CLI or {interactive, TUI, non-CLI} awesomeness. Let's discuss the CLI first, then the TUI. Either way, you just need to know the

  • commandline options to use. Following text uses long options (for ease of searching documentation), but of course short options are also available.
  • commandline argument to use
  • output format string to use

The most basic commandline to show which installed software packages use the most disk space is probably

aptitude search --sort '~installsize' --display-format '%p %I' '~i' | head

so let's break that down:

  • --sort is package sort order, and ~installsize specifies a package sort policy.
  • installsize means 'sort on (estimated) installed size', and the preceding ~ means sort descending (since default for all sort policies is ascending).
  • --display-format changes the <you guessed :->. The format string '%p %I' tells aptitude to output package name, then installed size.
  • '~i' tells aptitude to search only installed packages.
  • ... and, unless you have very few installed packages (my kinda-generic Debian workstation has over 2400), you want to pipe to head or less or a file, or maybe just wc -l to see how many lines aptitude will be returning.

You might also want to

  1. specify the line width (in characters) for aptitude to use when displaying, with --width <your desired integer value/> . aptitude will default to what it believes to be your terminal width, but sometimes it guesses wrong, and sometimes you wanna write to a file, etc.
  2. display more information in your format string, or change field widths. E.g., my enhanced format string '%30p %I %r %60d' displays
  • %30p : package name in field width=30 char
  • %I : estimated install size
  • %r : 'reverse depends count': approximate number of other installed packages which depend upon this package
  • %60d : package's short description in field width=60 char

Note that, if you don't see changes in your output field, you probably need to set --width.

... and you can also do this sort of thing in the {interactive, TUI} aptitude. E.g., to set display format preference,

  • click or navigate to Options->Preference
  • scroll to The display format for package views
  • add %I to the current value in the position desired

To limit search to installed packages in the interactive aptitude,

  • press l (lowercase L)
  • enter ~i in the dialog

To sort on installed size in the interactive aptitude,

  • press Shift-S (uppercase S)
  • enter installsize in the dialog


  • 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
    Commented Jan 22, 2014 at 17:31
  • @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
    Commented Jan 22, 2014 at 17:39
  • @Braiam yes, what is the total amount of space gained if I remove *texlive*?
    – terdon
    Commented Jan 22, 2014 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
    Commented Jan 22, 2014 at 17:46

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
  • I noticed that dpigs actually has the same result as dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -nr | head, which is the top ten of installed packages that occupy the most space. Still, dpigs is simple and short.
    – user125388
    Commented May 24, 2018 at 5:27

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}'); 

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.


to add to other answers, if you like command line you can use good old durep

# durep -td 1 /etc                         # or -td 2
[ /etc   319.4K (60 files, 43 dirs) ]
  90.2K [########                      ]  28.26% apache2/
  27.5K [##                            ]   8.62% apt/
  23.7K [##                            ]   7.43% mime.types
  19.7K [#                             ]   6.18% cron.daily/
  18.7K [#                             ]   5.87% services
  18.0K [#                             ]   5.64% security/
  14.7K [#                             ]   4.61% init.d/
  13.2K [#                             ]   4.13% ssl/
  11.1K [#                             ]   3.48% ld.so.cache
   9.0K [                              ]   2.81% locale.gen
   7.8K [                              ]   2.43% pam.d/
   4.5K [                              ]   1.42% default/
   4.3K [                              ]   1.35% skel/
   2.9K [                              ]   0.92% locale.alias

You can probably free up space using localepurge

# dpkg-reconfigure localepurge
# localepurge
localepurge: Disk space freed in /usr/share/locale: 26160 KiB
localepurge: Disk space freed in /usr/share/man: 1304 KiB

Total disk space freed by localepurge: 27464 KiB

Finally, you can probably get rid of icons and fonts that sometimes can take a lot of space. See details at this website


(examples extracted from ownyourbits)

  • dpkg-reconfigure localepurge complains about localepurge package not being available.
    – Rolf
    Commented Jan 19, 2018 at 10:53

Adding a few more tools to the list, I've always used debfoster and deborphan on my systems. They're most useful for hunting old dependencies that are hanging around after upgrades.

apt-get autoremove is great, but doesn't get everything and since it follows the installation marks, it doesn't quite always know what you wish to keep. Using apt-mark lets you direct it to some extent, though.

Check also: https://wiki.debian.org/ReduceDebian


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.

  • To make your root partition explode, simply install texlive. That should do it :) The debian (bullseye) default partitioning scheme is to blame, IMHO, recommending a ludicrously small amount of space for the root partition (23G in my case on a 1TB disk). If they defaulted to like 50GB or 100GB, most use cases would be covered.
    – BitTickler
    Commented Oct 1, 2022 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .