apt vs apt-get: Explained For Beginners!

When I was a beginner in Linux and I wanted to install any software, the online instructions I found would ask me to type something like this on my Ubuntu’s terminal

sudo apt install <software name>

or sometimes like this

sudo apt-get install <software name>

So I used to wonder what are these apt and apt-get commands. In this article, I am trying to explain the need for these commands and what they do internally to install software and how they do it.

The Fundamentals

Before we could understand the specifics of apt and apt-get commands, we must be able to answer the following question

How does commands work?

Here is a video we made to the answer to the question above!

Now that we have covered the fundamentals lets get back to the topic!

What is apt? apt stands for “Advanced Packaging Tool”. It is a package manager that is used for managing the installation, updating, and removal of software packages in a Debian based Linux system.

That’s the short version of the answer, but don’t worry if you don’t understand it completely as this article is all about breaking down the above answer into parts and learning it in detail!

Let’s take this short answer and highlight the important terms that we need to understand.

It is a package manager that is used for managing the installation, updating and removal of software packages in a Debian Based Linux System.

If you look at the above 2 lines from a beginner’s perspective a lot of questions come into mind. Some of these are

  • What are these software packages?
  • What is a package manager?
  • What are the functions of a package manager?
  • Why only Debian based system?
  • What are other alternatives for apt that I can use on my Debian based system?

Let’s try to learn the answer to all these questions in detail in this article.

I have already written another article explaining all about packages and package managers in detail that you can find in the link below.

A Beginners Introduction To Linux Package managers: apt, yum, dpkg & rpm

In that article, I have explained

  • What are packages in a Linux system
  • Content of packages
  • Need for package managers
  • Functions of package managers and
  • the architecture of packages managers

If you haven’t already, please go ahead and read that one before continuing this article as that article should clear up most of the confusion that is common with beginners who would like to learn more about “apt” commands.

Alright, I guess by now, you have read that article and you are more familiar with the role of package manager like “dpkg” (which stands for Debian package manager) in our Ubuntu Linux systems. Let’s next talk about apt and apt-get.

Why there are 2 of these commands? apt and apt-get?

Both these commands are just different methods of invoking our package manager dpkg. The “apt-get” command is the older of these 2 and “apt” is just a refreshed version with more focus on making things simpler for the end-user. You can use both to do the same thing in most cases

For example, if you want to install Firefox on your system, you can either enter the command

sudo apt install firefox

or

sudo apt-get install firefox

But as we saw the “apt” command is meant to be short, simple and focussed on the end-user’s experience. An example is the addition of the progress bar while we install packages on the command line as shown in the screenshot below.

Let’s take a look at a comparison of apt and apt-get.

aptapt-get
Newer version command to act as a front-end for APTOlder version command to act as a front end for APT
Has progress barNo progress bar
Has limited functionality Has more functionality, and it’s used with bash-scripts more than apt because of guaranteed backward compatibility

Next, let’s have a look at the comparison of apt and apt-get commands

aptapt-getAction
apt install <software name>apt-get install <software name>Installs a software
apt remove <software name>apt-get remove <software name>Removes software but keeps configuration (user settings) files
apt purge <software name>apt-get purge <software name>Removes and deletes configuration files
apt updateapt-get updateupdates packages list
apt upgradeapt-get upgradeupgrades software to their latest versions
apt full-upgradeapt-get dist-upgradeupgrades packages and removes old unnecessary ones
apt autoremoveapt-get autoremoveremoves unnecessary dependencies
apt search <keyword>apt-cache searchsearches packages based on keyword
apt showapt-cache showpkgshows information about a package like version, dependencies, etc,.
apt listlists packages based on certain criteria
apt edit-sourcesedits sources.list file with some sanity checks

Other than the ones listed above, the “apt-get” family of commands has more commands that have no substitute yet in the “apt” family. Some examples include

apt-get build-dep
apt-get check
apt-get download
apt-get changelog
apt-get clean
apt-get autoclean
apt-get changelog
apt-get indextargets

Just type

man apt-get
man apt-cache

to get a list of options supported by apt-get and apt-cache

I leave it unto you to read the man pages and try out these commands for yourself and play with them!

When to use apt and when to use apt-get?

It is recommended to use apt commands on the terminal and apt-get on the bash scripts.

This is because “apt” being the newer version is constantly evolving and can sometimes break backward compatibility. For example, the commands that worked in version 1.7 of apt may or may not work in 2.0.

If we were to use apt on our scripts then we need to go into the script files and edit them again version after version till its finalized. For this reason, the “apt-get” family of commands is preferred over “apt” as they have guaranteed backward compatibility.

Also apt-get family has more functionality for usage in scripts that will give the programmer more control over the required outcome.

Isn’t “apt” a short form for “aptitude”?

Yes and No!

The word “aptitude” in English means “a natural ability to do something.’ and apt as we saw stands for Advanced Packaging Tool.

But Linux developers have developed another tool named “aptitude” (named it that way just for fun since most people tend to think apt stands for aptitude as both these words kinda sound similar!). This tool provides a simple GUI inside the command line for easy management of packages. You can invoke this program using the command

sudo aptitude

and this will take you to a GUI that looks like this

I leave it to you to play around and explore the options it provides!

What does “Debian based system” mean?

There are 2 types of Linux distros

  1. Original distributions
  2. Derived distributions

Making a Linux distro from zero involves a lot of work to put all the packages and the Linux kernel together into a single “distributable” Operating system.

Original distributions are those that are made this way from zero. In other words, these original ones take the kernel, GNU utilities, application software, etc. and combine them into an installable operating system and distribute them to the end-users usually over the internet. Popular examples of original distros include Debian, RedHat, Slackware, etc.

Derived distros are ones that take one of these original distributions, make some changes to it, so that its more suitable for a specific purpose and then distribute them as an installable operating system.

Debian is the original distro here that used “apt” and “apt-get” and all the distros derived from it also use the same package management system as their defaults. Some examples of Debian derived distros include the Ubuntu family (Ubuntu, Lubuntu, Kubuntu, etc), Linux Mint, Kali Linux and PureOS. You can read more about these derivatives over at Debian.org in this link.

Will “apt” only work on Debian based system?

No, you can use the “apt” tool on other systems too. But like I explained in this article apt can only work with dpkg package manager that works with packages in the .deb format. So the packages you that we are trying to install or remove or update must be in the .deb format!

For example, you can’t open an excel “.csv” document using Microsoft word and expect it to work just fine. Similarly apt tool can only work with .deb files!

You can still use apt on Red Hat based distros or other Linux distros using tools like “alien” which converts between .deb and .rpm package formats, but the hassle to make everything work is not worth the effort, as conversions will bring their own set of problems in some circumstances.

So my advice is to stick to the default package managers that come with the Distros and learn their commands instead of trying to fit a square peg into a round hole!

And with that, I will conclude this article!

I hope you guys enjoyed this article and learned something useful. 

You can email us or contact us through this link if you have any questions or suggestions. 

If you liked the post, feel free to share this post with your friends and colleagues!

Photo of author
Editor
Balaji Gunasekaran
Balaji Gunasekaran is a Senior Software Engineer with a Master of Science degree in Mechatronics and a bachelor’s degree in Electrical and Electronics Engineering. He loves to write about tech and has written more than 300 articles. He has also published the book “Cracking the Embedded Software Engineering Interview”. You can follow him on LinkedIn

Comments are closed.