One of the noticeable features introduced on Ubuntu 16.04 was the ‘introduction’ of apt command. The reality is that the first stable version of apt was released in the year 2014, but people started noticing it in 2016 with the release of Ubuntu 16.04.
It became common to see apt install package
instead of the usual apt-get install package
.
Eventually, many other distributions followed Ubuntu’s footsteps and started to encourage users to use apt instead of apt-get.
You might be wondering what’s the difference between apt-get and apt? And if they have a similar command structure, what was the need for the new apt command? You might also be thinking, if apt is better than apt-get, should you use the new apt command or stick with the good old apt-get commands?
I’ll explain all these questions in this article and I hope that by the end of this article, you’ll have a clearer picture.
Before we see the difference between apt and apt-get, let’s go into these commands' backdrop and what they try to achieve.
Why was apt introduced in the first place?
Debian, the mother of distributions like Ubuntu, Linux Mint, elementary OS etc., has a robust packaging system; every component and application is built into a package installed on your system. Debian uses a set of tools called Advanced Packaging Tool (APT) to manage this packaging system. Don’t confuse it with the command apt, it’s different.
Various tools interact with APT and allow you to install, remove and manage packages in Debian based Linux distributions. apt-get is one such command-line tool that is widely popular. Another popular tool is Aptitude with both GUI and command-line options.
If you have read my guide on apt-get commands, you might have come across several similar commands, such as apt-cache. And this is where the problem arises.
You see, these commands are way too "low-level", and they have so many functionalities which are perhaps never used by an average Linux user. On the other hand, the most commonly used package management commands are scattered across apt-get and apt-cache.
The apt commands have been introduced to solve this problem. apt consists of some of the most widely used features from apt-get and apt-cache, leaving aside obscure and seldom-used features. It can also manage apt.conf file.
With apt, you don’t have to fiddle your way from apt-get commands to apt-cache. apt is more structured and provides the user with the necessary options needed to manage packages.
What is the difference between apt and apt-get?
The apt command is a smaller section of the apt-get and apt-cache options. The apt command gives the end user just enough tools to install, remove, search and update APT packages. The apt-get command has a lot more options that are useful for writing low-level scripts and tools.
So with apt, you get all the necessary tools in one place. You won’t be lost under tons of command options. The main goal of apt is to provide an efficient way of handling packages in a way “pleasant for end users”.
When Debian says “pleasant for end users”, it actually means that. It has fewer but sufficient command options but in a more organized way. On top of that, it enables a few options by default that are actually helpful for the end users.
Progress bar
For example, you see the progress bar while installing or removing a program with apt command.
Listing upgradable packages by default
apt also prompts you with the number of packages that can be upgraded when you update the repository database.
You can achieve the same with apt-get as well if you use additional command options. apt enables them by default and takes the pain away.
Kernel upgrades
Another difference is how the 'upgrade' option behaves in the two commands.
In apt-get, the upgrade option cannot install new packages on its own:
under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed
But in apt, the upgrade option can install new packages:
New packages will be installed if required to satisfy dependencies, but existing packages will never be removed
What's the big deal you ask? Well, it means that when you run apt upgrade
, it can upgrade the Linux kernel. apt-get upgrade
cannot do that.
Why? Because even though you are upgrading an installed Linux kernel version, you actually install a new Linux kernel (whose package name is different). And thus to the system, it is like installing a new package that was not already installed.
As I stated from the man page of apt-get command, the upgrade
option cannot install a new package and hence it cannot upgrade the kernel version. To upgrade the kernel with apt-get, you'll have to use the dist-upgrade
option.
This is another example of the user-friendliness of the apt command over the apt-get command.
Difference between apt and apt-get commands
While apt does have some similar command options as apt-get, it’s not backward compatible with apt-get. That means it won’t always work if you just replace the apt-get part of an apt-get
command with apt.
Let’s see which apt command replaces which apt-get and apt-cache command options.
apt command | The command it replaces | Function of the command |
---|---|---|
apt install | apt-get install | Installs a package |
apt remove | apt-get remove | Removes a package |
apt update | apt-get update | Refreshes repository index |
apt upgrade | apt-get upgrade | Upgrades all upgradable packages |
apt autoremove | apt-get autoremove | Removes unwanted packages |
apt full-upgrade | apt-get dist-upgrade | Updates packages with auto-handling of dependencies |
apt search | apt-cache search | Searches for the program |
apt show | apt-cache show | Show package details |
apt has a few commands of its own as well.
New apt command | Function of the command |
---|---|
apt list | List packages woth criteria (Installed, upgradable, etc.) |
apt edit-sources | Edit sources list |
One point to note here is that apt is under continuous development. So you may see a few new options added to the command in the future versions.
If you are interested in learning more, I recommend reading my guide that shows how to use apt commands with examples.
Is apt-get deprecated?
I didn’t find any information that says that apt-get will be discontinued. And it actually shouldn’t be. It still has a lot more functionalities to offer than apt.
For low-level operations like scripting, developing CLI tools that deal with APT packaging etc, apt-get will still be used.
Should you use apt or apt-get?
You might be thinking if you should use apt or apt-get. And as a regular Linux user, my answer is to go with apt.
apt is the command that is recommended by the Linux distributions. It provides the necessary option to manage the packages. Most important of all, it is easier to use with its fewer but easy to remember options.
I see no reason to stick with apt-get unless you are going to do specific operations that utilize more features of apt-get.
Conclusion
I hope I was able to explain the difference between apt and apt-get. In the end, to summarize the apt vs apt-get debate:
- apt is a subset of apt-get and apt-cache commands providing necessary commands for package management
- While apt-get won’t be deprecated, as a regular user, you should start using apt more often
So what do you think? Are you already using apt or do you want to stick with the good old apt-get? Share your views in the comment section below.