For many people coming for the first time into Debian-based Linux distros, package management may seem convoluted. Some tutorials tell you to use “apt,” others “apt-get,” and some really old or specific ones use “aptitude.” It’s high time to get down to the absolute minutiae and explain the “why, where, what, and how” of the strange and somewhat divided world in this little corner of the Linux universe.
Clearing the Apt Confusion
Regardless of all the small details that distinguish them,
aptitude are all just different calling cards for Debian’s package management system that interacts with online repositories. As if there weren’t enough of these already, there’s also one more package management tool in Debian you may have heard of that deals with on-disk installations:
The latter is a tool you use every time you download a .deb package from the Web and double-click it to install, much like you would an MSI package in Windows. Solus has EOPKG, Fedora has RPM, and Arch has AUR. Even Android has packages known as APKs, and the single largest repository for its packages is the Google Play Store. You can hopefully now see how familiar Linux’s structure is to other operating systems – even those not operating on desktop or laptop computers specifically.
Aptitude is the nerve center for the APT, acting as a front-end that you can use if you want to have a detailed look at all the packages that your distro offers in its repositories and those that you’ve added. It’s also one of the few old-school clickable GUIs that run directly inside the terminal.
What Is APT?
Known as the Advanced Packaging Tool, APT is Debian’s solution to mainstreaming the process of removing, installing, searching for, and managing the various applications you install in the operating system. Every distro based on it uses APT, though not all applications of APT are equal. We’ll get to this in a bit.
For now, it’s important to note that APT as a package manager is not the
apt command. It instead encompasses a variety of APT-related commands like apt-get, apt-mark, and apt-cache.
What Distros Use APT?
If your distro is described as “Debian-based,” it uses the APT tool in one way or another. This includes but isn’t limited to:
- Linux Mint
- MX Linux
- Kali Linux
- Raspberry Pi OS
- Elementary OS
- SteamOS (no longer Debian; moved to Arch in 2021 for Steam 3.0)
There are many, many more distributions based on Debian, so if you’re using something that isn’t listed here, check whether the
apt-get command works by simply typing it in your terminal. If your terminal returns to you with a confused message about the command not existing, then you’re definitely not on anything touched by Debian.
Apt-get vs. Apt
In many tutorials online involving the installation of a package, you’ll see
apt being used interchangeably as commands on any Debian-based system. When it comes to installing and removing stuff, there is indeed no difference which command you use. Just don’t confuse this for the two being versions of each other.
Remember how I said
apt-get is simply one of a few other commands in the Advanced Packaging Tool? For someone who’s new to APT, it can be a little bit disorienting to have to memorize which commands are valid for
apt-cache. For example, did you know that the command to search for a package is
What if all three of these commands’ most useful functions for day-to-day life were unified?
This is exactly what the
apt command does by itself. These three letters, when typed into your terminal, act as a “wrapper” for the APT ecosystem, simplifying the process for people who spend much of their time scribbling at their terminals.
When searching for a package,
apt search should mostly return the same results as
A Word on APT Flags
If you paid close attention to the images showing the outputs of both search commands, they show slightly different information. That’s because the
apt command grabs information about the status of the application in your system in addition to whatever
apt-cache search puts out.
Now is probably a good time to explain what that “i” meant next to the package name in the output of
apt search. It’s a flag placed by aptitude, the front-end of the Debian package tool.
Here’s a list of flags you’ll see in your terminal and what they mean:
A– Automatically installed, perhaps as part of a larger meta-package or the installation of the operating system itself.
B– The package is flagged as broken and must be reinstalled.
H– Half-installed. The package needs to finish installing.
c– The package was removed, but its “ghost” lingers on in the form of configuration files. You can solve this by using
apt purge, followed by the name of the package with this flag.
p– Package purged or was never installed.
v– The package is generically used by others to provide a function. For example, Firefox provides browsing capabilities that can be used by other applications, making it a virtual package.
i– This package is installed in your system.
h– There’s a hold on this package, preventing it from being updated to newer versions.
Not All Apts Are Equal!
Before going any further into the topic of package management, it’s extremely important to note that the
apt command may have more available arguments in one distro than it does in another. For example, Ubuntu’s lacks “hold” while Mint has it.
To fully take in what I’m saying here, we need to have a look at the Ubuntu and Mint listings for what arguments you can pass in
apt and see the sheer chasm between the two.
This one is Ubuntu on my newly minted (pun intended) test-bed for tutorials.
And here is Linux Mint.
By far, Mint has the most fleshed-out wrapper of all Debian-based distributions I’ve seen up until now. This isn’t surprising when you realize it was tailor-made by the community that maintains Mint to cater both to starters who just want to install their apps in peace with a short command and to the turbo-geeks who want to tune everything just the way they want with millimeter precision.
The Ultimate Guide to APT Commands
There’s no better way to understand the power of the APT package system than sinking your teeth into some important commands. The list will consist of APT commands followed by the
apt simplification, where it’s applicable, in parentheses. If the simplification does not work in your particular distro, it’s either because yours hasn’t included it for some reason or you’re not running Mint’s behemoth of a wrapper. In that case, you can safely fall back on the vanilla command without losing too much.
apt add-repository) – Adds a new repository to your list of software sources from a package maintainer.
For example, if I want to add Lutris’s current repository for Mint 20, I can type either
sudo add-apt-repository or
sudo apt add-repository, followed by
ppa:lutris-team/lutris. Each repository is unique, and most application developers that don’t have packages found in the official ones for your distro will include instructions that will point you in the right direction.
apt autoremove) – Often used together, these two commands sweep out the dust in your system in the form of lingering install scripts and installation media you no longer need (
clean), as well as automatically freeing your storage of packages that no one uses or depends on (
sudo apt autoremove && sudo apt clean will hoover all the cobwebs from your main drive in one single line in your terminal.
apt changelog) – Spot the latest changes in a package.
apt-get changelog brave-browser will tell me what the latest version of the Brave browser includes compared to its last revision.
apt contains– Found only in Linux Mint and maybe a few other Ubuntu-derived distros, this command is what you use when you encounter a “file not found” kind of error in a program. With some luck,
apt containswill find that file for you in some far-flung folder from an application you installed!
apt contains gettext.sh will look for the application that contains the shell script for
gettext. If you have
gettext-base installed in your Mint distro, you should find it immediately!
apt install) – As the name implies, it installs a package. Passing the
--reinstallflag on the
apt-getcommand will immediately reinstall your package.
Example of installing:
sudo apt-get install firefox. Example of a Firefox reinstallation:
sudo apt-get install --reinstall firefox. A more simple variant through the
apt wrapper is
sudo apt reinstall firefox.
apt remove) – Another frequently used tool in the terminal cave-diver’s arsenal. This command will uninstall anything that was installed either by the APT ecosystem or the DPKG package manager.
sudo apt remove grub-customizer.
apt update) – this command does not update the applications in your system. It simply refreshes the APT cache so that your system can compare the versions available in your repositories with what’s currently installed on your system. It’s checking for updates but not performing them.
apt upgrade) – This will download updates to your packages that your system found if they are available. You generally don’t have to close anything that’s running to perform this.
showhold) – This series of commands manages your held applications. Holding a package tells your operating system not to update it in the future. With
unhold, you can initiate or cancel an update hold on an application. The
showholdargument will list what you currently have on hold.
sudo apt hold pulseaudio. A word to the wise: holding updates on packages that others depend on may damage your system in the long term if you’re not certain what you’re doing.
show) – This lovely pair of commands bonds well together. Use the first to find a package, then use
showfollowed by the package’s full name to find out more details about it.
sudo apt search gimp.
If you wish to read up more on the intricacies of APT for your particular distro that may not have been covered here, their manuals are right in the terminal. Just type
man before the command without any further arguments, press Enter, and presto!
The Dreaded “apt-get command not found” Issue
If you can’t install anything on your terminal because APT just went poof and disappeared, this isn’t the end of the world. With a little bit of elbow grease, you’ll have your favorite package manager up and running.
First of all, if this is a new system, just double-check that it’s supposed to be using APT as a package manager. Fedora uses DNF/yum, Arch uses Pacman, Solus uses EOPKG, openSUSE uses zypper, Mandriva uses urpmi, and you can find a whole bunch of others in this handy cheat sheet. Just type those letters in a terminal to be absolutely sure.
Once we’re sure you’re in a Debian-based system and APT is indeed missing, it’s time to move on to the next step.
To walk you through this with a little extra stake in the matter, I will now cripple my Ubuntu system and will not allow myself the easy escape of reinstalling the OS!
The result is now either a “command not found” error or an inability to process the command.
Now it’s time to go and find the APT package appropriate for our system and install it. Since we don’t have APT to work with, we can’t automatically download the dependencies either.
Luckily, Debian’s on-disk package manager (
dpkg) is here to save the day! I downloaded the latest version of the apt package corresponding to my CPU architecture from Ubuntu’s main repo and ran
dpkg -I on it to list the dependencies I needed to install.
In my case, upon attempting to install the latest version of APT, the dependencies were all there but were not recent enough.
You find these things out when you type
dpkg -i /path/to/your/apt/deb/file. Obviously, you need to replace that phony path I typed with whatever path corresponds to the .deb file you downloaded from the website.
Instead of version 2.3.11, I chose to go for version 2.0.6, which is what is installed in Mint at the time of writing.
After fiddling around with versions here and there, you’re going to eventually stumble upon one that works with your current setup. This is exactly what happened to me. After typing
sudo dpkg -i followed by the package, it magically installed smoothly.
Generally, APT’s most dire dependencies are things your system wouldn’t be missing. However, since you’re missing APT, anything’s possible. In any case, if you find that you lack one of the dependencies listed after looking with
dpkg -I like we discussed earlier, have a look through the parent folders in the repository I linked. They should be in their corresponding alphabetical folders.
Frequently Asked Questions
1. Are there unsafe APT commands?
Generally, if you type anything APT-related in your terminal, you should be aware of what that command is about to do. Before major updates, especially those where you install a new kernel, make a full backup of your system just to be safe.
All that aside, the commands you have to really be careful with are
apt hold and
dist-upgrade. The former may break your system until you lift your holds as mentioned earlier in more detail. The latter is only useful when your distro releases a new long-term version that you’d like to migrate to, but it will also potentially remove installed packages that you were accustomed to using. You’re in much safer territory by performing a normal
apt upgrade, then doing an
apt autoremove to clear out the packages truly gathering dust.
2. Is Apt better than Apt-get?
I know this is a tired statement, but it really does depend on what you’re doing. Are your fingers getting rug burn from typing so many commands? You may want to use
apt as a shortcut if you don’t need something specific that
apt-get would be more suitable for. In many ways, apt not only streamlines the package management process but also provides extra information like we saw earlier when comparing
apt-get search to
However, if you’re not on Mint with its gargantuan argument list for
apt that almost entirely renders
apt-get superfluous, you might feel good about having something more old-school to fall back on.
3. What’s the difference between a repository and an app store?
To the day-to-day user, the differences aren’t staggering at all. In fact, they can be extraordinarily comparable. Where they begin to part ways is in software “fungibility.” Linux has a very fluid software market where users are presented with a sometimes-overwhelming amount of choice. Smartphone app stores are pretty much set in stone, and it’s hard to imagine users seeking alternatives.
At the same time, in theory, the personal package archives (PPAs) that people enjoy using in Ubuntu can be compromised and lead to the proliferation of malicious software by bad actors.
If there’s one thing to take away from this, it’s that decentralization comes with some responsibility on the part of the user. Make sure that the repositories you add to your distro are from sources you can trust and projects that have stood for a long time.
Hopefully, by this point you’ve been able to observe just how much power is afforded to you when you understand just what APT’s full suite of commands and tools can offer. It’s more than just a way to add and remove software from your computer; it’s a full complex framework that allows you to discover and make more informed choices about what you put there.
Read on to learn how to run Bash commands in the background on Linux and 15 Linux LS commands you need to know.