This article is all about demystifying the commands “apt upgrade” and “apt full-upgrade” and their differences!
For those of you in a hurry, here is the short version of the answer!
apt upgrade vs apt full-upgrade: In a Nutshell
What is the difference between the command “apt upgrade” and “apt full-upgrade“?
- apt upgrade is the command used to download and apply any available updates to your packages in a safe manner by not removing packages that are previously installed in a given Linux system,
- while “apt full-upgrade” command is used to do the same thing except if needed previously installed packages are removed to make the upgrade happen.
The table below explains the same without so much jargon!
As you can see from the table, the main difference between these 2 commands is
full-upgrade will remove software packages if necessary while upgrade won’t, which makes apt upgrade safe to use and full-upgrade not so safe!embeddedinventor.com
That’s “apt upgrade vs apt full-upgrade” in a nutshell!
The reason why full-upgrade can require caution is explained in more detail later on in the article where the following questions are addressed
- Why full-upgrade needs caution?
- How to prevent broken packages when using full-upgrade?
- Why do we even have full-upgrade if it is not so safe?
You can jump to the section of interest using the table of contents below.
Also, 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 upgrade vs apt full-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 decided to put together everything I learned into an “easy-to-digest” article so that it can be useful for beginners!
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 a video we made to the answer to the question above!
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 upgrade
what you are doing is opening an application named apt and clicking the button named upgrade!
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 upgrade and full-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.
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!)
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!
Now that we understand what apt is and how it works, we are ready to answer the question
What does apt upgrade do?
The apt upgrade command simply updates the apps installed to the latest versions available in the repos!
For example, say you have Firefox version 107.0.1 installed on our system, but a newer version, say 112.0.4 is available in the repo.
After running the sudo apt upgrade command, Firefox will be updated to the latest version (v112.0.4 in our example).
This is what the official description of apt upgrade command looks like
If you want a deep dive into the technical details of what apt upgrade does, then go ahead and read the article linked below!
Next, let us move on to understanding the apt full-upgrade command.
What does apt full-upgrade do?
In essence, when we run the apt full-upgrade command, we are saying to the apt package manager that we trust it to uninstall packages as it deems necessary.
This is what the official description of apt full-upgrade command looks like
Another key difference here is the intention
- apt upgrade is for “regular maintenance” while
- apt full-upgrade is for upgrading the system as a whole.
For example, say we wish to upgrade the Ubuntu version from 22.04 to 22.10. Then in such situations, the packages that came with 22.04 might be obsolete on 22.10 due to the following reasons
- The developer stopped maintaining this package
- None of the software in the new release depends on this package
- The package name has been changed.
Any one of these is a good reason to remove packages from the repos to keep them operating smoothly.
When using apt full-upgrade apt is free to decide whether to keep or remove these packages depending on what it knows about a given package.
Why apt full-upgrade needs caution?
Case#1: Custom Software
One corner case where this might do you more harm than good is when you may have some custom software on your Linux system that may be dependent on the older packages, and these custom software which you have built and installed yourselves might not be known to the apt tool, so removing that package might not be the best thing to do!
Case#2: Dependency Conflicts
Also apt has a smart conflict resolution system, which can delete some packages to satisfy changing dependencies while upgrading. To give you a general idea consider the following example.
Say you have 2 games installed on your PC
- Angry Birds 1.0
- Super Mario 1.0
Say your present graphics card driver version is 1.0, and both these games depend on this driver and run fine for now.
Let’s say Angry Birds has been updated to version 2.0 in the latest distro release and this version of Angry Birds needs Graphics card driver version 2.0 to be present.
The repos for the new distro release does not have graphics card v1.0 which is needed by Super Mario v1.0. This creates a conflict of dependency.
Apt‘s smart conflict resolution system might decide to remove graphics card v1.0 as this is not available anymore in new distro releases, but then this might break Super Mario!
A reason why some drivers might stop working in new releases could be the fact that the kernel got updated and with that, the support for old drivers got removed.
Hence, running a full-upgrade might mean you might not be able to play Super Mario anymore as there is no guarantee that Super-Mario-V1.0 will be compatible with graphics card driver v2.0.
Preventing broken packages while using apt full-upgrade
So best practice is to read what packages will be removed before typing Y and pressing the Enter key!
Debian recommends the following 13-step procedure before performing a full upgrade
If you are lucky like me, the “full-upgrade” command might not need to remove any packages as shown in the screenshot below.
In my case, the outputs of both upgrade and full-upgrade commands look the same as there were no package conflicts, and hence no removal was needed!
So long story short: use full-upgrade with caution, especially if you are messing with production servers!
Why do we even have full-upgrade?
You might ask if full-upgrade is not safe why do we even have this?
Distributions like Ubuntu do not support a single release forever. For example, their LTS (Long Term Support) releases are only good for a 5-year period, which means they will only get security updates for 5 years. At the end of this period, you cannot just do apt upgrade anymore to get the latest fixes.
If you are hosting a website, then running it on a server that is not updated can lead to hackers stealing your data. So if your distro version is near the expiry of its service period, then you have 2 options
- Reinstall the latest version and set up your website and all of its services manually or
- Do a full-upgrade, this way you do not need to set things up again from scratch all over again!
Ofcourse as mentioned in the previous section do a full backup before performing this else you might end up with a broken system!
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!