Which installed software packages use the most disk space on Debian?
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
Easiest is to run wajig large
. The package should be an apt-install
-away.
Here's two links for other ways of doing it:
List your largest installed packages (on Debian/Ubuntu)
LIst all installed packages in size order
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
.
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'
tellsaptitude
to output package name, then installed size.'~i'
tellsaptitude
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
orless
or a file, or maybe justwc -l
to see how many linesaptitude
will be returning.
You might also want to
- 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. 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
References:
- for
aptitude
package search patterns, see https://aptitude.alioth.debian.org/doc/en/ch02s04s05.html#tableSearchTermQuickGuide - for
aptitude
package sort policies, see https://aptitude.alioth.debian.org/doc/en/ch02s05s01.html#secSortingPolicy - for
aptitude
output display format, see https://aptitude.alioth.debian.org/doc/en/ch02s05s01.html#secDisplayFormat