apt vs. apt-get
apt vs. apt-get
The apt command-line utility is a successor to the well known apt-get, offering simpler installation and maintenance for the DEB packages used with Debian, Ubuntu, Knoppix, and many other Linux distros.
The Debian package management infrastructure is a simple yet powerful system that has been a distinguishing feature of Debian since the project's early years. At the core of the Debian package management is dpkg [1], a low-level tool used for installing and removing Debian .deb
packages. The bigger and more comprehensive Advanced Package Tool (APT) [2] is a higher-level tool that includes dpkg on the back end. APT performs most of the other functions associated with a package management system, including integrating external repositories.
The APT package system supports a number of front-end applications, both command-line and GUI-based, that act as a user-friendly interface for managing Debian packages. In the past, most users who wanted to work at the command line depended on the classic apt-get
tool as an interface to the Debian package system. Through the years, apt-get
and a constellation of other supporting utilities, such as apt-cache
, have provided nearly effortless package management for Debian users, as well as users of Debian-based distros like Ubuntu and Knoppix, who take the time to master the commands.
However, some users were not happy about the complex, and often confusing, system of apt-get
commands and options. Since the release of Debian 8 "Jessie" and Ubuntu 16.04 "Xenial Xerus," all users of Debian-based systems can enjoy a new command-line interface to the APT system: apt
. The apt
utility consolidates features that were once spread among apt-get
, apt-cache
, and other commands, and it simplifies many of the command options for an easier and friendlier user experience.
The apt
utility has been used in the Debian "Unstable" edition since 2014, and it became official with Debian 8. Because apt-get
still works in recent releases of Debian and other Debian-based distros, many users have not taken the time to learn about apt
. This article introduces the apt
package management tool and explores some of the differences between apt
and apt-get
.
Note: The apt
tool discussed in this article is not the same as the apt
Python wrapper created by Linux Mint developers a few years ago.
apt vs apt-get
apt
does not guarantee downwards-compatibility with apt-get
, but many (though not all) command options are interchangeable. For a full comparison, type apt --help
and apt-get --help
and compare the results.
Table 1 shows some of the important commands side by side. As you can see, many commands are the same if you just exchange apt-get
for apt
. One exception is the apt upgrade
command. The old command: apt-get upgrade
installed the latest versions of all packages currently installed on the system from the repository, but it didn't remove existing packages or retroactively add dependencies. The new apt upgrade
installs new packages when they are added as dependencies of packages to be updated, although it still doesn't remove previously installed packages.
Table 1
Differences
Function | apt-get | apt |
---|---|---|
Install package |
apt-get install <package> |
apt install <package> |
Remove package |
apt-get remove <package> |
apt remove <package> |
Remove package including configuration |
apt-get purge <package> |
apt purge <package> |
Update sources |
apt-get update |
apt update |
Update packages (without removing or reinstalling) |
apt-get upgrade |
apt upgrade1 |
Update packages (with removing and reinstalling) |
apt-get dist-upgrade |
apt full-upgrade |
Remove unnecessary dependencies |
apt-get autoremove |
apt autoremove |
Search package |
apt-get search <package> |
apt search <package> |
Display package information |
apt-cache show <package> |
apt show <package> |
Display active package sources in detail |
apt-cache policy |
apt policy |
Display available and installed package versions |
apt-cache policy <package> |
apt policy <package> |
New Commands |
||
Edit packages sources |
– |
apt edit-sources |
List packages by criteria |
dpkg --get-selections > list.txt |
apt list |
Set/change package status |
echo <package> hold | dpkg --set-selections |
apt-mark <package> |
1 Corresponds to apt-get upgrade --install new-pkgs |
The new command structure offers subtle improvements that save time and extra steps. For instance, apt-get
lets you move a package to /var/cache/apt/archives/
and then install the package using apt-get install package_name
, and the software automatically manages the dependencies. apt
eliminates the need to push things around; all you need is apt install package_name
, specifying the full path if necessary.
Design Error Corrected
apt
fixes some errors of the original apt-get
implementation. For example, in addition to apt-get
for editing Debian packages, the legacy system used the apt-cache
command for outputting information about the packages. The new apt
command thoroughly cleans up, combining functions from both old commands and structuring them in a better way. apt
provides features of the most commonly used apt-get
and apt-cache
commands, adding useful information that once required additional options.
For example, apt-get update
only reports execution at the end (Figure 1), but apt update
shows the number of updatable packages and offers an option to display a structured list of possible updates (Figure 2). This list even provides a better overview, adding color to the otherwise drab display (Figure 3).
![](/var/linux_magazin/storage/images/issues/2018/208/apt-vs.-apt-get/figure-1/722335-1-eng-US/Figure-1_large.png)
![](/var/linux_magazin/storage/images/issues/2018/208/apt-vs.-apt-get/figure-2/722338-1-eng-US/Figure-2_large.png)
![](/var/linux_magazin/storage/images/issues/2018/208/apt-vs.-apt-get/figure-3/722341-1-eng-US/Figure-3_large.png)
The actual package update command has been given a new visual element: Both apt upgrade
and apt full-upgrade
or apt dist-upgrade
now show a progress bar that informs users of the update progress (Figure 4).
![](/var/linux_magazin/storage/images/issues/2018/208/apt-vs.-apt-get/figure-4/722344-1-eng-US/Figure-4_large.png)
The update bar also appears when removing packages with apt remove
or apt purge
. apt remove
removes the package itself, and apt purge
removes the entire associated configuration – if it is located outside the home directory: apt
never tampers with configurations in the user directory.
Two New Commands
The apt show
command sorts the output alphabetically and suppresses some less important information that you might see with apt-cache show
. The dist-upgrade
parameter is assigned the more significant name of full-upgrade
, although the two commands behave in the same way.
The apt list
and apt edit-sources
commands are new: apt list
in connection with the --installed
or --upgradeable
options outputs lists of the installed or upgradeable packages; apt edit-sources <List>
opens /etc/etc/apt/sources.list.d/
with the specified list in the editor for editing (Figure 5).
![](/var/linux_magazin/storage/images/issues/2018/208/apt-vs.-apt-get/figure-5/722347-1-eng-US/Figure-5_large.png)
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.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.