Authors Top

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Introduction

The Advanced Packaging Tool (APT) is a high-level package management tool in Ubuntu and other Debian Linux distribution derivatives. The APT tool also includes the following commands:

  • apt-get
  • apt-cache
  • apt-config

In this tutorial, we’ll learn the difference between apt and apt-get utilities.

2. The apt Utility

The apt utility is a command-line interface for the package management system. It combines the most commonly used commands from apt-get and apt-cache. Also, apt is designed as an interactive end-user interface.

While apt does have some similar command options as apt-get and apt-cache, it’s not completely backward compatible with these commands. Therefore, we can’t simply substitute apt for apt-get in any apt-get command.

For example, let’s see the difference by using the update and upgrade commands of apt.

2.1. Updating Packages With apt

First, we’ll fetch data on new updates for packages on the system. Here, we’ll use the following command:

$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:2 http://ng.archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
...
Get:39 http://ng.archive.ubuntu.com/ubuntu jammy/universe i386 Packages [7,474 kB]
Get:40 http://ng.archive.ubuntu.com/ubuntu jammy/universe Translation-en [5,652 kB]
61% [40 Translation-en 3,191 kB/5,652 kB 56%] 
...
Fetched 22.8 MB in 47s (488 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
214 packages can be upgraded. Run 'apt list --upgradable' to see them.

Notably, there’s info at the end of the apt update command output:

214 packages can be upgraded. Run 'apt list --upgradable' to see them.

From the output, apt gives the total number of packages available for upgrade. Also, it includes the apt list –upgradable command to list these upgradable packages.

2.2. Listing Packages With apt

The update command updates the package cache. However, it doesn’t provide a complete list of all available updates.

To list all the upgradeable packages, we can use the apt list –upgradable command:

$ sudo apt list --upgradeable
Listing... Done
alsa-ucm-conf/jammy-updates,jammy-updates 1.2.6.3-1ubuntu1.1 all [upgradable from: 1.2.6.3-1ubuntu1]
apt-utils/jammy-updates 2.4.8 amd64 [upgradable from: 2.4.6]
apt/jammy-updates 2.4.8 amd64 [upgradable from: 2.4.6]
bind9-dnsutils/jammy-updates,jammy-security 1:9.18.1-1ubuntu1.2 amd64 [upgradable from: 1:9.18.1-1ubuntu1.1]
bind9-host/jammy-updates,jammy-security 1:9.18.1-1ubuntu1.2 amd64 [upgradable from: 1:9.18.1-1ubuntu1.1]
...

Here, the apt list –upgradable command lists all upgradable packages. In addition, it shows the new upgrade version and gives us a hint on the version change as in the example:

[upgradable from: 1.12.20-2ubuntu4]

Notably, the apt list command works with flags like –installed or –upgradeable. Also, the terms “upgradeable” and “upgradable” work alike.

2.3. Upgrading and Installing Packages With apt

Again, the apt upgrade command downloads and installs the newest versions of all packages on the system at a time. Having set our local system to align with the remote repository, let’s upgrade the system with the available updates:

$ sudo apt upgrade -y
...
The following packages will be upgraded:
gdb ghostscript ghostscript-x gir1.2-gdkpixbuf-2.0 gir1.2-gnomedesktop-3.0 gir1.2-gtk-4.0 gir1.2-mutter-10 gjs gnome-control-center
...
204 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
65 standard security updates
Need to get 557 MB of archives.
After this operation, 17.5 MB of additional disk space will be used.
Get:1 http://ng.archive.ubuntu.com/ubuntu jammy-updates/main amd64 gzip amd64 1.10-4ubuntu4.1 [96.0 kB]
Get:2 http://ng.archive.ubuntu.com/ubuntu jammy-updates/main amd64 perl-modules-5.34 all 5.34.0-3ubuntu1.1 [2,976 kB] 
...
Fetched 5,135 kB in 4s (1,175kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
setting xserver-xorg-legacy/xwrapper/allowed_users from configuration file
(Reading database ... 138477 files and directories currently installed.)
Preparing to unpack .../gzip_1.10-4ubuntu4.1_amd64.deb ...
...
Progress: [ 46%][###########################.......................................................................]

The output shows a progress bar, a unique feature of the apt program. This feature makes the apt utility more user-friendly when we compare it to the apt-get command.

In addition, we can enable or disable the install progress bar using the 99progressbar file. To set the progress bar, we’ll create the 99progressbar file in the /etc/apt/apt.conf.d directory. Then, we’ll enter the following setup in the file:

Dpkg::Progress-Fancy"1";

Alternatively, we can use the echo command to set the progress bar. First, we need to access the command line as root:

$ sudo su

Further, using echo, let’s configure the progress bar:

# echo 'Dpkg::Progress-Fancy"1";' > /etc/apt/apt.conf.d/99progressbar

Lastly, we’ll key in exit to leave the root shell access:

# exit
exit

Now, we can see the progress bar when we install new packages on the system. Further, to disable the progress bar, we simply need to clear the configuration in the 99progressbar file.

Next, let’s see the apt-get utility and understand how it differs from the apt command.

3. The apt-get Utility

The apt-get suite is also an APT command-line tool for handling packages in Linux systems. Notably, we can use the apt-get command to carry out several tasks:

  • updating packages
  • upgrading packages
  • removing packages
  • cleaning the local repository

Further, let’s see the variation between the apt and apt-get commands using its update and upgrade controls.

3.1. Updating Packages

We can use apt-get to keep packages up-to-date with changes from the source repository.

To illustrate, let’s install new updates on our Linux system. First, we’ll update the system repository using apt-get update. Naturally, we need admin access (sudo) to run the command:

$ sudo apt-get update
[sudo] password for user: 
Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB] 
Get:2 http://ng.archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Ign:3 http://dl.google.com/linux/chrome/deb stable InRelease
...
Get:39 http://ng.archive.ubuntu.com/ubuntu jammy/universe i386 Packages [7,474 kB] 
Get:40 http://ng.archive.ubuntu.com/ubuntu jammy/universe Translation-en [5,652 kB] 
61% [40 Translation-en 3,191 kB/5,652 kB 56%] 
...
Fetched 22.8 MB in 47s (488 kB/s) 
Reading package lists... Done

Here, the apt-get command fetches data on new updates for packages in the system. Also, we can notice the variation at the start of the lines:

  • Hit: shows that there’s no change in the package version
  • Get: signifies that a new version of the package is available
  • Ign: implies that the program ignores the package

Again, unlike the apt update command, apt-get doesn’t give the total number of packages available for upgrade. Also, it doesn’t include any hint on the command to list these upgradable packages.

Next, we’ll download and install available updates using the apt-get upgrade command.

3.2. Upgrading and Installing Packages

Having set up our system up-to-date with the remote repository, let’s download and install the changes available. The apt-get upgrade command downloads and installs the updates in one go:

$ sudo apt-get upgrade -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
gdb ghostscript ghostscript-x gir1.2-gdkpixbuf-2.0 gir1.2-gnomedesktop-3.0 gir1.2-gtk-4.0 gir1.2-mutter-10 gjs gnome-control-center
...
204 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
65 standard security updates
Need to get 557 MB of archives.
After this operation, 17.5 MB of additional disk space will be used.
Get:1 http://ng.archive.ubuntu.com/ubuntu jammy-updates/main amd64 gzip amd64 1.10-4ubuntu4.1 [96.0 kB]
Get:2 http://ng.archive.ubuntu.com/ubuntu jammy-updates/main amd64 perl-modules-5.34 all 5.34.0-3ubuntu1.1 [2,976 kB] 
...
Fetched 5,135 kB in 4s (1,175kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
setting xserver-xorg-legacy/xwrapper/allowed_users from configuration file
(Reading database ... 138477 files and directories currently installed.)
Preparing to unpack .../gzip_1.10-4ubuntu4.1_amd64.deb ...
...

Here, the -y flag adds the validation apt-get needs to carry out the process. Further, let’s see the apt commands and how they differ from apt-get.

4. apt vs. apt-get

The apt commands have slightly different setup options than their apt-get equivalents. The following table shows the apt commands and their apt-get counterparts:

apt Command Equivalent apt-get Command
apt update apt-get update (with colored output)
apt upgrade apt-get upgrade –with-new-pkgs
apt install, apt reinstall, apt remove, apt purge identical to their apt-get commands (adds progress output during the dpkg run)
apt full-upgrade apt-get dist-upgrade
apt autoremove apt-get autoremove
apt satisfy apt-get satisfy

These commands do the same thing. However, there are other apt-get commands. They would return error messages when we replace apt-get with apt for such.

5. Conclusion

In this article, we saw the contrast between apt and apt-get. In addition, we depicted the variance using common system administration tasks.

Authors Bottom

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!