The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

Discover the dissimilarity between apt and apt-get on Linux Gain insights into the Debian Package Management System and understand the chain of command Explore how to install applications using Apt and learn about other useful commands Make informed decisions on whether to use apt or apt-get for your Linux needs

Key Takeaways

apt-get and apt are both tools within the Debian Package Management System.

apt-get is a comprehensive tool to interact with dpkg, whereas apt is a simplified yet more user-friendly alternative to apt-get.

Both apt and apt-get share common commands such as install, remove, purge, update, upgrade, and autoremove. However, apt offers additional commands like search, show, list, and edit-sources.

Why do Debian-based Linux distributions include both apt and apt-get? Is apt intended to replace apt-get or do they serve different purposes? We will clarify the connection between these two commands.

The Debian Package Management System

Creating a Linux distribution involves a significant focus on designing and developing a package management system for users to easily install and uninstall software packages. This process necessitates the software to retrieve package files from the software repository and ensure proper installation on users' computers.

Undertaking this task is not insignificant. Apart from the software engineering aspect, hosting software repositories requires a considerable amount of time, dedication, and financial investment. This is one of the key reasons why numerous "new" Linux distributions are derived from existing ones.

This results in Linux distributions being organized into families or genealogies, like the ones based on Debian, Red Hat, Arch, and others.

The Debian family, which includes Ubuntu and all its derived distributions, utilizes the Debian Package Manager. This manager operates with package files that have the ".deb" file extension, commonly known as DEB files. DEB files are compressed files that contain additional archive files. These archive files consist of the executable files, man pages, libraries, and more, associated with the respective application.

To install software from a DEB file, you must unpack its component files and properly position them on your computer. This process involves interacting with the operating system and the desktop environment, which ensures that the application appears in application searches and allows its icon to be included in docks or system menus.

This purpose is fulfilled by both the apt-get and apt commands. However, the presence of two commands for the same task begs the question: why?

The Chain of Command

The process responsible for carrying out the installation is referred to as dpkg. It comprises a set of commands such as dpkg-split, dpkg-trigger, and dpkg-divert. These commands are utilized by the tools within the Advanced Package Tool suite, or APT. APT, another assemblage of tools, incorporates apt-get, apt-cache, and apt.

The dpkg command is considered a low-level command, with numerous complex options beyond basic interactions. To simplify usage, the apt-get command acts as a front end to the dpkg suite. Unlike dpkg, apt-get is designed to interact directly with users rather than serving as a background command. However, apt-cache is still used alongside apt-get to display information. Additionally, the apt command offers a more user-friendly approach to communicate with dpkg, offering a large subset of apt-get's features and also incorporating functionality from apt-cache.

The Differences Between apt and apt-get

A noteworthy mention goes to Linux Mint for their unique implementation of apt. The Linux Mint team has designed their own apt version, a Python wrapper for apt-get. However, it is important to note that this is not the apt we are discussing. The apt we are referring to is the widely used Debian apt, which was first introduced in 2014 and gained popularity when it was integrated into Ubuntu 16.04 in 2016.

dpkg is a low-level background application, while apt-get is a comprehensive yet simplified interface to dpkg. On the other hand, apt is a more user-friendly version of apt-get that offers some streamlined features. It is worth noting that apart from providing an effortless interface to dpkg, both apt-get and apt go beyond its capabilities. They are capable of fetching files from repositories and attempting to resolve missing dependencies and conflicts.

There are several common commands between apt and apt-get. All of these commands can be preceded by either apt or apt-get and will have the same behavior:

install packagename: Install a package.

remove packagename: Remove (uninstall) a package.

purge packagename: Remove a package and its configuration files.

update packagename: Update the repository information.

upgrade: Update all packages.

autoremove: Remove libraries and other packages that are no longer required.

The apt full-upgrade option replaces the apt-get dist-upgrade option.

These are new commands for apt:

apt search: Search for a package name in the repositories. This is the same as apt-cache search

apt show: Show information about a package. This is the same as apt-cache show .

apt list option: Shows lists of installed or upgradeable packages.

apt edit-sources: Directly edits the list of repositories that apt searches in for packages.

Installing an Application with Apt

To verify the existence of a package in the repositories or confirm its correct name, you can utilize the apt search feature. For instance, suppose you intend to install Scribus but are unsure about its package name. In this situation, you can attempt searching for scribus-desktop.

apt search scribus-desktop

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

That search didn't find anything. We'll try again with a shorter, more generic, search clue.

apt search scribus

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

Several results can be obtained, and one of them is "scribus", which appears to be the central package for the Scribus desktop publishing application. To gather further information, we can use the apt show command.

apt show scribus

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

We get a dump of information about the package, including what will be installed and a description of the software.

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

It also suggests other packages that might be required, depending on our needs.

To install the package we need to use sudo.

sudo apt install scribus

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

The files are retrieved from the repositories. The file currently being retrieved is highlighted in brown.

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

When the files have been retrieved they are installed. The progress through the installation is shown as a percentage displayed in digits and as a progress bar.

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

Other Commands

The apt list and apt edit-sources commands are options in apt that don't exist in apt-get.

To view the applications installed on your computer, utilize the apt list command with the --installed or --upgradeable options, which will show both the installed packages and those that can be upgraded.

apt list --installed

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

Scrolling through the output, we can see two entries for our newly installed Scribus application.

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

To see if any of the installed applications can be upgraded, use the --upgradeable option.

apt list --upgradeable

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

The apt command also provides a way for you to edit the information stored about the repositories apt searches for packages. Only do this if you know what you're doing.

sudo apt edit-sources

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

This command opens your default editor and loads the file holding the repository information.

The Ultimate Showdown: Apt vs Apt-Get – Unraveling the Differences in Linux

Should I Use apt or apt-get?

The apt-get command does not receive frequent updates, which is actually beneficial. This is because it needs to ensure backward compatibility. However, apt, on the other hand, is treated as a user-facing command and its backward compatibility is not as big of a concern.

For day-to-day use, use apt.

If you script anything to do with package installation, use apt-get. That gives you the greatest chance of portability and compatibility in your scripts.