Skip to content

Instantly share code, notes, and snippets.

@fairhopeweb
Created April 11, 2022 21:18
Show Gist options
  • Save fairhopeweb/905a87c07b37e21a3732c34455e16f7f to your computer and use it in GitHub Desktop.
Save fairhopeweb/905a87c07b37e21a3732c34455e16f7f to your computer and use it in GitHub Desktop.
Using Nala instead of APT Ubuntu - Commands & Tutorial
linuxiac.com
Nala: A Prettier Frontend for the APT Command
5-7 minutes
Nala is a frontend for APT so that you can have prettier output, faster downloads of packages, and a history. Here’s how to use it.
APT – You’ve likely typed it hundreds, if not thousands of times. So why not use Nala to make things easier and prettier?
If you’re searching for a more attractive CLI tool to conduct most APT terminal operations, Nala is a good option. In short, Nala is a libapt-pkg frontend.
Sometimes it can be difficult for novice users to comprehend what apt is trying to accomplish while installing or upgrading. And this is where Nala comes on the scene.
The goal of Nala is to fix this problem by removing some redundant messages, improving package formatting, and using color to illustrate what will happen with a package during installation, removal, or upgrade.
Why Use Nala Instead of APT?
Nala
There were ultimately three significant reasons why using Nala instead of APT.
1. Parallel Downloads
Parallel downloads are the most compelling argument to choose Nala over APT.
As you probably know, APT downloads only one package at a time, while Nala may download multiple at once. Nala can download up to 16 packages per unique mirror in your sources.list file. Therefore, it can theoretically download 16 times quicker than APT.
Nala has a limit of two threads per mirror to reduce how hard you hit mirrors. To enhance download speeds even more, Nala alternates downloads between available mirrors. So, if a mirror fails, Nala goes on to the next until all defined mirrors have been exhausted.
2. Select the Fastest Mirror
The nala fetch command works similarly to netselect and netselect-apt in most cases. But nala fetch will determine whether your operating system is Debian or Ubuntu. Then Nala will grab all of the mirrors from each master list. After that, it will perform a latency test and assign a score to each mirror. Finally, the quickest three mirrors will be selected and written to a config file by Nala.
3. Package Management History
If you’re familiar with the dnf command, nala history works much in the same way. It stores each install, remove, or upgrade in /var/lib/nala/history.json with a unique ID number. So you can call nala history at any time to print a summary of every transaction you’ve ever made.
On top of that, you can manipulate the packages with commands such as nala history undo ID or nala history redo ID.
How to Install Nala
Ubuntu and Debian users are able to install Nala by typing the commands shown below:
echo "deb [arch=amd64,arm64,armhf] http://deb.volian.org/volian/ scar main" | sudo tee /etc/apt/sources.list.d/volian-archive-scar-unstable.list
wget -qO - https://deb.volian.org/volian/scar.key | sudo tee /etc/apt/trusted.gpg.d/volian-archive-scar-unstable.gpg > /dev/null
sudo apt update && sudo apt install nala
Alternatively, you can also download the .deb installation package from the project’s GitLab Releases page and install it locally by using apt.
How to Use Nala
Keep in mind that most apt commands must be run as a user with sudo privileges.
Fetch Updates & Upgrade Packages
Before any operations with nala, you need to ensure that your local copy of the package database is up-to-date. Without this, the system won’t know if there are newer packages available or not.
The nala update command downloads up-to-date information about available software packages and upgrade the system.
sudo nala update
Updating Packages with Nala
Installing New Packages
Once your packages database is updated, you can install any packages with the nala install command. For example, let’s install Nginx Web Server:
sudo nala install nginx
Installin a Package with Nala
Removing Packages
To remove (uninstall) an installed package, use the nala remove command. For example, to remove a package called nginx, enter:
sudo nala remove nginx
Removing Package from the System by Using Nala
History
To see past transactions of packages installed via the nala command, run nala history:
sudo nala history
Past Transactions of Packages Installed via Nala
Complete List of All Nala Commands
The general syntax of the nala command is:
nala [--options] <command>
Commands:
install: Install packages
remove: Remove packages
purge: Purge packages
update: Update package list and upgrade the system
upgrade: Alias for update
fetch: Fetches fast mirrors to speed up downloads
show: Show package details
history: Show transaction history
clean: Clears out the local repository of retrieved package files
Optional arguments:
-h, --help: Show help message and exit
-y, --assume-yes: Assume ‘yes’ to all prompts and run non-interactively
-d, --download-only: Package files are only retrieved, not unpacked, or installed
-v, --verbose: Logs extra information for debugging
--no-update: Skips updating the package list
--no-autoremove: Stops Nala from autoremoving packages
--remove-essential: Allows the removal of essential packages
--raw-dpkg: Skips all formatting and you get raw dpkg output
--update: Updates the package list
--debug: Logs extra information for debugging
--version: Show program’s version number and exit
--license: Reads the licenses of software compiled in and then reads the GPLv3
You can find more information about Nala on the project’s GitLab page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment