Managing your Debian packages with debfoster
Command Line – debfoster
When it comes to weeding out unnecessary packages on your Debian system, debfoster lets you conveniently arrange all your housekeeping functions into a single command.
Debian was one of the first distributions to have a modern package system. Over the decades, a whole ecosystem of related commands has grown up around it, including front ends like apt-get
and, more recently, apt
for the basic package manager dpkg
, and then utilities ranging from apt-file
for searching files inside packages to apt-cache
for searching packages. In fact, a search on "apt" in the Stable repository for Debian 10 returns 54 hits, while a search on "deb" returns 68. One of the lesser-known but handier members of this ecosystem is debfoster [1]
, whose main purpose is to weed out unnecessary packages. However, like apt
, debfoster
actually combines several other functions, displaying information on currently installed packages, and serving as a replacement for apt-get
.
You can start to use debfoster
by running the command without options or targets to create a database of packages that you want to keep installed. This first session takes at least 20 minutes on an average system, since every installed package is queried. However, once the database is populated, later sessions generally only refer to a handful of packages. If you find that you have accidentally kept a package – which is easy to do the first time as your responses become automatic – you can exit and try again.
Once the database is created, debfoster
can be run in two ways: by running it after packages have been installed or removed or as an alternative means to install and remove packages. To install a package, use the structure alongside another command with debfoster PACKAGE(S)
. To remove packages, add a minus sign (-
) before the list of packages.
Either way, debfoster
concludes by detecting orphans: packages that were installed as a dependency, but are no longer needed because of changes to the system. apt-get
and apt
, of course, perform the same function, but only give the choice of using the autoremove
sub-command to delete them. By contrast, debfoster
gives a wider variety of choices (Table 1). For one thing, the default is to keep the package (Figure 1), while apt-get
and apt
simply keep repeating their message about orphans each time they start. For another, you can choose to delete only the package (n) or its dependences as well (p) or view package information (i) before a decision is made. Similarly, you can exit debfoster
instead of answering, committing the changes already indicated or without saving any of them. More importantly, many packages have no dependencies and are not detected by the basic package manager as orphans, and these may linger long after they are no longer wanted. All in all, debfoster
offers a more hands-on, less accident-prone approach to package management that advanced users may appreciate.
Table 1
debfoster Response Choices
|
Yes |
Keep the package (default) |
|
No |
Delete the package |
|
Prune |
Also deletes any package dependencies; a list of these packages displays above the prompt |
|
Skip |
Will be asked again the next time |
|
Help |
Summary |
|
Information |
Displays package details |
|
Undo |
Works on last response |
|
Quit |
No packages removed; all changes lost |
|
Exit |
Makes changes to |
Command Options
debfoster
's options begin with a number of queries about installed packages. --show-keeper
(-a
) lists files to be kept (Figure 2), --show-orphans
(-s
) lists dependencies that are no longer needed (Figure 3), --show-depends PACKAGE
(-d
) or --show-related PACKAGE
(-r
) lists the packages that the specified package depends on (Figure 4), and --show-providers PACKAGE
(-p
) lists the package for which the specified package is installed only as a dependency – something that rarely happens in recent releases. More likely, --show-providers
may return a message of Installed Package or Not a Dependency, which limits its usefulness. The other query options, though, are useful for knowing what packages to keep. The number of orphans can be particularly surprising, especially if you install packages from outside the official repositories.
Other options affect how debfoster
runs. To guard against mistakes, --mark-only
(-m
) does a dry run so you can see the results of your answers before anything is deleted. If you decide the results contain no surprises, then you can run debfoster
with the --force
(-f
) option to have all deletions made. You can also run it with --quiet
(-q
) to assume that all answers are Yes, in order to update the keepers list. Should you be transferring files from one machine to another, you may want to use --config FILE
(-c
) to create a clean configuration file (see below) or --keeperfile FILE
(-k
) to create a clean database and then replace the transferred files with the newly-created ones. In addition, the usual --verbose
(-v
) option can sometimes give you a more detailed look at what is happening.
In its role as an apt-get
or apt
replacement, debfoster
can also take --upgrade
(-u
), with or without packages specified.
Configuring debfoster
The default configuration file for debfoster
is /etc/debfoster.conf
. All fields in the file are case-insensitive, and the most commonly used fields (Table 2) are first in the file. If desired, an alternate configuration file can be specified using the option --config FILE
(-c
). Half a dozen fields are the commands for which debfoster
is a front end. For the most part, these fields do not need to be changed, although if you are in the habit of using apt
, you probably want to change InstallCmd
's value to apt install
.
Table 2
Configuration Fields and Their Defaults
Field | Default | Meaning |
---|---|---|
|
|
Standard installation command |
|
|
Standard command for removing packages |
|
|
Standard command to review information on a single package |
|
|
The file where the list of orphans is stored |
|
|
The file that lists information about which packages are at least partly installed |
|
|
The file that lists available packages |
|
|
Sets status of packages about which to ask questions. By default, questions will be asked about packages with the priorities |
|
|
Will not upgrade packages with the |
|
|
Will not remove packages marked as essential |
|
|
Dependencies will be installed along with the package |
|
|
Packages installed with recommended packages |
|
|
Suggested packages will not be installed |
|
|
Makes packages grouped using |
|
Takes a comma-separated list of packages that should always be kept |
|
|
List the sections you are never interested in (e.g., possibly |
|
|
List name extensions for packages that you want to group with their based packages (e.g., |
|
|
|
Remembers explicit removals of packages. If a package that has been removed is then reinstalled, it is removed again without asking. Set to |
|
|
Get detailed information about operations, as with the |
|
|
No questions are asked when the package is removed, as with the |
|
|
No interaction on any packages, as with the |
Other fields can affect how debfoster
operates. Some fields, like MaxPriority
or UseHold
are based on package settings, while others like Verbose
or Quiet
set options for debfoster command. Fields in /etc/debfoster.conf
can be overwritten by command-line options, particularly --ignore-default-rules
(-i
), which suppresses the settings for the UseHold
, UseEssential
, MaxPriority
, KeepSections
, and NokeepSections
fields.
A Convenient Arrangement
debfoster
adds nothing new to the Debian package manager. Its functions are spread over a number of different commands. Rather, its strength lies in its convenient rearrangement of functions in a single command. Moreover, aside from the number of possible answers to questions, it is quick to learn, with options that most command-line users will have seen in other commands. As a result of these advantages, using it can tell you things about your packages that you could find elsewhere, but probably won't, because to do so is inconvenient. If you care about running as lean a system as possible, debfoster
quickly justifies the few minutes needed to learn its basic workings.
Infos
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.