An improved front end for Apt

Apt on Steroids

© Photo by Lopez Robin on Unsplash

© Photo by Lopez Robin on Unsplash

Article from Issue 267/2023

The Nala front end for Debian's Apt package manager combines the reliability of the Apt tools with easier to read output and speedier downloads.

Debian's package management system for the command line relies on dpkg [1] in the background and the Advanced Package Tool (Apt) [2] with its default front end, apt. While apt usually does a reliable job, its command-line tools (based on the libapt-pkg and libapt-inst libraries), such as apt, apt-file, apt-policy, and the like, are not particularly clear-cut or attractive. In addition, the Apt front end is slow.

This, along with other shortcomings in the tools available in Debian, prompted longtime Debian developer, Michael Stapelberg, to announce his retirement in 2019 with some harsh criticism [3]. Stapelberg subsequently created the proof of concept distri distribution, with the goal of optimizing package management in general (Linux Magazine previously covered distri in July 2021 [4]).

Nala, which was inspired by Fedora's DNF package manager, steps up to eradicate these shortcomings, offering easier to read output and increased speed thanks to parallel downloading.

What Apt Does

As part of Apt on Debian, Ubuntu, and their derivatives, apt is the interactive command-line utility that takes care of package management. It performs tasks such as installing, uninstalling, or searching for packages and displaying information about them. While apt does not offer color-highlighted output (Figure 1), it does at least have a progress bar. You can interact with apt through subcommands such as update, upgrade, full-upgrade, install, remove, and purge. The packages installed via apt are based on the repositories entered in the source list below /etc/apt/sources.list.d/.

Figure 1: With apt, the output for updating the source list is a mess of information without any clear focus on important facts.

Since the beginning of the year, another Apt front end named Nala has been making the rounds. Unlike apt, Nala uses the python-apt [5] library. This library provides access to almost all the features supported by Apt's underpinnings, the libapt-pkg and libapt-inst libraries. It's only logical that front-end programs for Apt, such as Nala, can be written in Python.

Although still quite new, Nala can already be found in the repositories of distributions such as Debian Testing and Unstable, Kali Linux, MX Linux, Raspbian Testing, and Ubuntu 22.04 backports. For other Debian derivatives, you need to include the developer's repository as described in the wiki on GitLab [6]. Alternatively, you can download the tool as a DEB package and install it directly.

Currently, Nala version 0.11.1 can be used in the Bash, ZFS, and Fish shells. For Debian Stable, Ubuntu 21.04, and distributions based on their package set, you need to use the nala-legacy package, which provides the same functions and is only adapted to the older package set in terms of dependencies. You cannot use Nala with older distributions, such as Ubuntu 18.04 or Debian 10 (buster).

What Nala Offers

Because of the many changes, it is important to be able to intuitively understand the package manager's output during package installations or updates of the entire installation at the command line – especially if you use Debian Testing or Unstable, or other rolling release distributions based on DEB packages. This desire for clarity is one of the starting points for Nala: The output should be more accessible, detailed where necessary, and unobtrusive where possible. Nala achieves this goal by using more color highlighting and clearer output formatting (Figure 2).

Figure 2: With Nala, you can immediately see which repositories have been updated since the last update. In addition, the output also highlights ignored sources.

When called, Nala acts a little different from apt. The command

sudo nala update

has the same result as

sudo apt update

It updates the sources list in etc/apt/sources.list.d. On the other hand, if you type

sudo nala upgrade

Nala will run an

apt update && apt full-upgrade

as shown in Figure 3. This is because the developers designed Nala with rolling releases in mind. However, the command works just as well on stable distributions.

Figure 3: Nala highlights the new version of the packages to be upgraded in the right column when upgrading. The summary clearly shows the packages to be installed and upgraded, as well as the scope of the upgrade.

When updating, Nala highlights important aspects of the output in color, which shows at a glance which repositories offer new packages and to which version a package will be updated. In addition, the tool color highlights all of the repositories that it ignores due to an incorrect configuration or a missing key. While updating packages, Nala reliably shows you a progress bar with the remaining time, the completed workload as a percentage, and the number of packages already processed compared to the total update (Figure 4).

Figure 4: After successfully completing an upgrade, Nala will inform you about the progress and prompt you if a restart is needed.

One of Nala's less desirable quirks is to additionally integrate

sudo nala upgrade


sudo apt autoremove

which removes packages that are no longer needed (Figure 5). As experience shows, packages that are actually needed will still disappear from time to time. The recommended approach is to prevent this behavior by calling Nala with the --no-autoremove parameter.

Figure 5: If you do not want Nala to execute the autoremove command during an upgrade, you can prevent it in the configuration file.

Alternatively, you can prevent this behavior permanently in the /etc/nala/nala.conf file by setting the second entry to auto_remove = false. If you want Nala to clean up the package inventory, use the --autoremove parameter. In the configuration file, you will find some additional simplifying settings that Apt does not offer, which includes hooks that automatically perform scripted actions before or after installing a package. A video on Reddit explains this feature and shows an example [7].

If apt is indelibly embedded in your finger muscle memory, you can create an alias and keep using the familiar commands while Nala is working in the background.

What Slows Apt Down

Since 2002, the Debian developers have been resisting allowing parallel downloading from the same server on the grounds that it puts too much load on the servers while offering little gain [8]. Today, in view of HTTP/2 and soon HTTP/3, this argument needs to at least be verified. Other distributions have long since allowed parallel downloading from the same host. On Debian, you can install the apt-fast shell script wrapper from GitHub [9]; it drastically improves apt's download times by downloading packages in parallel, with multiple connections per host.

Nala makes apt-fast obsolete: Parallel downloading is already part of Nala's strategy. By default, Nala downloads three packages per unique mirror server in your source list. Also, Nala alternates downloads between available mirrors to boost speed further. If a server fails for any reason, Nala tries the next one until it has processed all defined servers.

And that's not all: You can run

sudo nala fetch

to tell Nala to test all available mirror servers for the performance at your location (Figure 6). In testing, Nala speed-checked 332 servers, resulting in a list of the 16 fastest German and European servers at our site. The first server in the list had a response time of 21ms, while the last clocked in at 28ms. You can enter the desired servers as a space-separated list of numbers and confirm by pressing the Enter key. Nala then writes the desired servers to a new source list named nala-sources-list and uses it from then on. It is a good idea to repeat this procedure every few months.

Figure 6: The nala fetch command checks all Debian mirrors and selects the fastest ones for your location.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • MX Linux 21.2 Offers Improvements and Bug Fixes

    MX Linux 21.2, aka “Wildflower,” is now officially available and is the second refresh of the MX-21 release.

  • Evolutionary Tale

    Over the past 30 years, the apt family has played an important role in dependency resolution for Debian distros.

  • News

    In the news: Fedora 37 Beta Available; Salix 15.0 Available for Installation with Lots of Updates and a More Modern Look; Ubuntu 20.04.5 LTS Release Now Available; MX Linux 21.2 Offers Improvements and Bug Fixes; Gnome Project Releases New Telemetry Data Collection Tool; Kubuntu Focus Announces New Desktop Model; and A New Release of Lightweight Linux Distribution SparkyLinux Now Available.

  • Dgit

    Dgit combines the Debian archive with a Git repository, giving package maintainers some totally new options for managing Debian source packages.

  • Command Line: Debian Goodies

    The Debian Goodies collection offers a variety of time-tested scripts to help you manage Debian packages.

comments powered by Disqus