apt update vs apt upgrade: Differences Explained!

This article is all about demystifying the commands “apt update” and “apt upgrade” and their differences!

For those of you in a hurry, here is the “Short Version” of the answer!

apt update vs apt upgrade: In a Nutshell

What is the difference between apt update and apt upgrade?

  • “apt update” updates the package sources list to get the latest list of available packages in the repositories
  • “apt upgrade” upgrades all the packages presently installed in our Linux system to their latest available versions.

The table below explains the same without so much jargon!

The “database” referred to in the first line in the table above refers to the database maintained by the Apt package manager.

This database contains a list of all the software packages installed in our systems with their present versions and the latest versions available in the cloud.

The simplified version is presented in the picture below.

You can think of the apt update command as a button that refreshes the list of available versions and the apt upgrade as a button that updates all the installed software to the versions listed in the “available version” column!

That’s “apt update vs apt upgrade” in a nutshell!

Don’t worry if the above answer does not make sense to you as that was targeted at more experienced programmers who just wanted to refresh their memories. The rest of this article is dedicated to those of you in the first steps of your journey to becoming a Linux Expert!

By the time you reach the end of this article, I suggest you come back and read this summary once more, I assure you it will make much more sense then!

apt update vs apt upgrade: A Thorough Explanation

When I was a complete beginner and I needed to install something on my Ubuntu machine, I went online and typed in “How to install <software name> on Ubuntu” and it usually led me to a page with some commands which looked like this

sudo apt update
sudo apt upgrade
sudo apt install <software name>

I was just happy that I was able to type something in the Terminal and see it actually working!

I did not pay much attention to what I actually typed in. I guess to beginners, it just feels like a magic spell to get our favorite software installed!

As time went on, so many of my Google searches led to using very similar patterns of “apt update” and “apt upgrade” commands to install stuff and my curiosity got the better of me, which inspired me to learn what these commands do and what happens in the background when you execute these commands.

I had to scour the internet and its forums for hours and hours to find the right information to understand what was going on back then as there was no “single” resource that answered all of my questions!

So I decided to put together everything I learned into this article so that you will have a much easier time understanding these concepts!

Without further ado, let’s begin!

Let us start with the following question.

How Do Commands Work?

For those of you who love learning via videos, here is one we made to explain this concept!

If you are looking for some quiet reading time, then skip the video and read on!

Nowadays we are all used to applications with fancy graphical user interfaces, with buttons to click and forms to enter data.

But back in the era when graphics hardware was not capable enough to handle fancy graphical user interfaces, people interacted with the computers with simple text-based commands.

This interface is called the Command Line Interface (CLI)

The structure of these “text-based commands” usually looks like this

<software name> <option to click inside software>

If apt were a modern-day application, its interface will likely look something like this

So when you type in the terminal

sudo apt update

what you are doing is opening an application named apt and clicking the button named update!

So next time you look at any Linux command don’t let all the jargon overwhelm you as it’s just an app with some buttons!

Before looking at what happens when you click on the update and upgrade buttons, let us first learn how apps are managed in a Linux system with apt.

What is apt and how it works?

If you are a complete beginner I highly recommend reading the article in the link below before continuing with this one.

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

Let us start our discussion by answering the following question.

What is apt?

APT stands for Advanced Packaging Tool, which is a tool used to manage apps a.k.a “software packages” that are installed in our system.

The words “manage” above simply refer to these 5 basic tasks

  • install software
  • remove software
  • upgrade software
  • upgrade system and
  • book-keeping/maintaining the list of software installed in our system

Also, it’s worth mentioning that apt is just the improved version of apt-get. apt essentially makes the user experience a little bit better by keeping things simpler. apt-get still has its uses though. If you wish to explore this topic further we have an excellent article on that topic linked below. (you can go ahead and skip the “Nutshell answer” section and start reading from the “Thorough Explanation” section!)

apt vs apt-get: Explained For Beginners!

Coming back to the topic, to understand the role of apt in our systems consider the following analogy.

If your computer is an office and your apps are employees then you can think of apt as the manager who is responsible for the hiring and firing of the employees (apps)

embeddedinventor.com

Now that we know what apt is, it is time to learn how apt works!

How apt works?

Similar to AppStore and PlayStore, Linux apps also come from marketplaces where developers can upload their apps and which are then verified to be free from malware and made ready to be downloaded.

In fact, the very idea of a “centralized location for storing verified software” originated in the world of Linux before it made it to iOS and Android!

These official “app stores” where you can find apps a.k.a “software packages” are called “repositories” in Linux.

apt enables you to keep track of what software is already installed on your system, what versions they are and what are the latest versions available in the market.

An oversimplified version of the apt’s database is presented in the picture below.

Every time we install or delete apps on our systems apt makes sure this database gets updated and maintained so that it portrays the present situation accurately.

Apart from the bookkeeping, apt also enables us to install, delete and update apps that are installed on our system by communicating with repositories in the cloud.

This is of course just the big picture and if you want to get into the nitty-gritty details we have a separate article on that which you can find in the link below!

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

Now that we understand what apt is and how it works, we are ready to answer the question

What does apt update do?

On our browsers, if we want to reload a webpage, we usually go for the small circle near the address bar.

When we click the refresh button, what happens is our browsers retrieve the page again from the server again to get the up-to-date version of the webpage.

Similarly, whenever we wish to update the “available version” column in the apt database we click the update button of apt!

On clicking refresh apt talks to the repositories in the cloud to get the latest available versions of each of the apps installed in our systems.

If you want a technically more accurate description of the apt update command, we can say

“apt update” updates the package sources list to get the latest list of available packages in the repositories

embeddedinventor.com

Here “package sources list” is just jargon for the list of software-packages (apps) available for installation on our computers.

If you want a deep dive into the technical details of what apt update does, then go ahead and read the article linked below!

sudo apt update: The Technical Details

Alright next let us look at the apt upgrade command (or should I say, the upgrade button of apt!)

Let us start by having a look at the picture below.

What does apt upgrade do?

I am sure by now you can already guess what “apt upgrade” does!

Yes, it simply updates the apps installed to the latest versions available in the repos!

Again, a more technically accurate description of the apt upgrade command would be

“apt upgrade” upgrades all the packages presently installed in our Linux system to their latest available versions.

embeddedinventor.com

So when we enter the “apt upgrade” command we tell apt to

  • compare the versions of all the presently installed packages with the ones in the list we have just downloaded through “apt update“.
  • if a more recent version is available in the cloud, the upgrade command downloads and installs those apps

so that they are up-to-date!

If you want a deep dive into the technical details of what apt upgrade does, then go ahead and read the article linked below!

“sudo apt upgrade” Command Explained For Beginners!

How do “apt update” and “apt upgrade” work together?

Another way of framing this question is

Why have 2 separate commands to update software?

The answer is there are situations where we don’t need to use them together! Maybe you need to install a specific newly released software and leave the rest of the system untouched. In that case, all you need to do is enter the following commands

sudo apt update
sudo apt install <package name>

See how we skipped the upgrade command!

If you really need to upgrade all the packages in your system in a single line of command, you can also enter the following command in the command line!

sudo apt update && sudo apt upgrade

Now that we understood the roles and functions behind these 2 commands, let’s take another look at the table of differences from the beginning of the article!

I hope this table makes much more sense now!

If you notice carefully, the last line for both these commands says “safe to use”. All it means is that if something breaks after running the commands it is usually “fixable”.

Regarding the apt update command, it does not mess with any software installed so it is obviously safe.

Regarding apt upgrade, it does not perform a full clean-up after the upgrade so that the data associated with your older version is still there on your hard disk in case you need it later on. If you wish to learn more about what I mean by “clean-up” and why apt upgrade does not do it, have a look at the following article!

“apt upgrade vs full-upgrade” Differences Explained For Beginners!

And on that note, I will conclude this article!

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

If your thirst for knowledge has not been quenched yet, here are some more articles that might spark your interest!

Related Articles

“sudo apt-get install” Command Explained For Beginners!

apt vs apt-get: Explained For Beginners!

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

Linux Distros That Uses apt commands for Package Management

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