# Which installed software packages use the most disk space on Debian?

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.

Unix & Linux Asked by Mirzhan Irkegulov on December 28, 2020

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

Correct answer by killermist on December 28, 2020

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

Answered by XTL on December 28, 2020

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

https://ownyourbits.com/2017/02/18/squeeze-disk-space-on-a-debian-system/

(examples extracted from ownyourbits)

Answered by nachoparker on December 28, 2020

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.

Answered by Lizardx on December 28, 2020

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


Answered by dfc on December 28, 2020

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


Answered by Faheem Mitha on December 28, 2020

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

References:

Answered by Braiam on December 28, 2020

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

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 "$it"$(sudo apt-get --assume-no --purge remove "$i" | grep "be freed" | awk '{print$4, $5}'); done  Answered by terdon on December 28, 2020 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


Answered by JosephH on December 28, 2020

## Related Questions

### Unable to change default bitrate of wireless network interface

1  Asked on December 6, 2020 by tanya-shreedhar

### External expansion drive is recognized by lsusb and dmesg, but not fdisk or lsblk

0  Asked on December 6, 2020 by rarelynecessary

### how to solve the error in cinder on openstack havana?

2  Asked on December 6, 2020 by dhamu

### Why does a SELinux problem get reported in /var/log/messages?

1  Asked on December 6, 2020 by robsch

### How to configure a GRE tunnel for ubuntu?

1  Asked on December 6, 2020 by natf2d

### How can an existing systemd service become unknown again?

0  Asked on December 6, 2020 by kolja

### rainerscript: how to log to file named \$programname substring?

1  Asked on December 6, 2020

### resolv.conf always empty

1  Asked on December 6, 2020 by marc

### how to disable the memory ballooning from OS linux side instead to disable it from Vsphere side

0  Asked on December 5, 2020 by yael

### Run a python script when connected to internet

1  Asked on December 5, 2020 by cutepoison

1  Asked on December 4, 2020 by flow2k

### Sending files/deirectories from local unix machine to remote unix sever

1  Asked on December 4, 2020 by beakal-begashaw

### Isolate non-FOSS “completely”

1  Asked on December 4, 2020 by user654789384

### Should localhost be managed by systemd-networkd?

0  Asked on December 4, 2020

### What is the difference between unbound and unwind?

1  Asked on December 4, 2020 by bex

### Exception ignored in: <_io.TextIOWrapper name='’ mode=’w’ encoding=’UTF-8′>

1  Asked on December 4, 2020 by elu

### Use ranger as my default file manager in i3wm

3  Asked on December 4, 2020 by sln

### How do I remove the first 300 million lines from a 700 GB txt file on a system with 1 TB disk space?

13  Asked on December 4, 2020 by kris

### How to install Intel Graphics drivers for Mint 13

2  Asked on December 4, 2020 by mbiber

### Attachments are missing when multiple files are attached in mail

3  Asked on December 3, 2020 by aravind