An improved front end for Apt
Apt on Steroids
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/
.
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).
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.
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).
One of Nala's less desirable quirks is to additionally integrate
sudo nala upgrade
with
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.
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.
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
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.