When I was a complete beginner and I needed to install something on my Fedora or CentOS machine, I went online and typed in “How to install <software name> on Fedora” and it led me to a page with some commands which looked like this
yum update
yum install <software name>
and sometimes the commands go like this instead
yum updgrade
yum install <software name>
And when we wish to update a particular command, the online instructions are presented sometimes like this
yum update <software name>
and some other times like this
yum upgrade <software name>
I was just happy that I was able to type something in the Terminal and it actually worked! 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 something installed!
As time went on, so many of my google searches led to using very similar patterns of “yum update” and “yum upgrade” commands to install stuff.
In plain English, update and upgrade have almost the same meanings, so it can get confusing for a beginner to understand what these commands actually do. Let’s see the difference between these 2 commands and what happens internally once you execute these commands.
What is the difference between yum update and upgrade? “yum update” updates all the presently installed packages to their latest versions that are available in the repositories and “yum upgrade” performs the same action as “yum update”, but once finished it also removes all of the obsolete packages from the system.
If a particular software is added to the “yum update” or “yum upgrade” command like
yum update <software name>
yum upgrade <software name>
then only the given software package and its dependencies are processed by the commands.
This is the short version of the answer. Let me expand what is written above with some more details.
The Fundamentals
Before we could understand the differences between these 2 yum commands, we must be first 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!
First, let’s try and understand what yum is and then let’s see what these lists contain and why they need to be updated time to time.
What is yum?
YUM stands for Yellow-dog Updater Modified which is a tool that is used to manage software in our system. The words “manage software” simply refer to these 5 basic tasks
- install software
- remove software
- upgrade software
- upgrade system and
- maintain the list of software that is installed in our system
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
What are packages in a Linux System?
Let’s start with this most basic question. Linux computer is basically made up of 3 parts
- The hardware
- The Linux Kernel and
- Software packages that work with the Kernel to give us a complete Operating System
Hardware, as we know, is CPU, HDD, SSD, RAM all the components that make up your system.
Kernel acts as an interface between software and hardware.
Software packages can be application software like text editors, word processors, etc. or they can be the GNU utilities like bash, cron, dd, etc., or they can be device drivers to talk to the hardware.
Next, let’s have a brief look at what is included in these “Packages”
Contents of packages
The content of the packages managed by these package managers involves the following 4 main components
- Binaries or the executable programs
- metadata files containing the version, dependencies, signatures and other relevant information
- documentation and manuals
- configuration files
These packages are stored in places called repositories.
What are Repositories?
This is the next question we must address. Repositories (or repos for short) are basically a place where verified packages are stored for easy retrieval and installation. They can be online like the YUM repository or they can be on a local folder or a DVD where you have a special collection of software that you need.
You can have several repositories from which you can download and install these packages. These can be
- official repos of your particular distro
- 3rd party repos
So basically what we are doing when we enter this “yum update” command is we are asking our Linux machine to go browse the repositories and compare the latest version of them with the ones that are installed in your system and update the ones that are not the latest version, along with all of the dependencies of a given software package!
Now that we understand what “yum update” does to our Linux machine let’s have a look at the “yum upgrade” command
“yum upgrade” performs the same action as “yum update”, but once finished it also removes all of the obsolete packages from the system.
The “yum upgrade” command once finishing the duties of the “yum update” command will remove the old version of the package along with the dependencies which have been just updated.
For example, consider this situation. Let’s assume that all the packages in the system are up-to-date with their version numbers equal to the ones presented in the list, except one, let’s call it “Package-X”, which has a version number of 2.4 while the list says version 3.0 is available. In this scenario, once we enter the “apt-get upgrade” command, your machine only upgrades this “Package-X” to the version 3.0. I hope you got the point!
What are dependencies for a given package?
Any software you install is built on top of other software and hence they are dependent on the base software to be present in the system for them to run on top of. That’s just the nature of the Software world. It’s just easier to build on top of an existing system than to reinvent the wheel each and every time!
For example, if you need to run a java-based application, then you need to have a Java Virtual Machine installed first. If you need to run python-based apps, then you need to have the python present. These are just some simple examples.
Practically any software will not just have one dependency, it can have tens and sometimes even hundreds of dependency packages.
So when we enter “yum upgrade” command we tell our Linux machine to first do the same action as “yum update” and update all our packages along with their dependencies and then once done, go ahead and delete the outdated packages and outdated dependencies!
For example if our package X uses python 2.2 and the “yum upgrade” command updated python 2.2 to python 2.3, then it will go ahead and delete the python 2.2 that is occupying unnecessary space in our system.
Is it not better to have just the “yum upgrade” to keep our machines clean without unnecessary packages?
The answer is there are situations where we cannot use the upgrade command.
Consider this situation. You have installed an app called Package Y from a 3rd party provider, and you did not install it using a package manager like yum and that needs python 2.2 to run properly.
If we install a software without the use of package managers like yum, then our system will not keep track of that particular software.
Now if you upgrade Package X, then python 2.2 will be removed as yum has no idea about your package Y and its dependency on python 2.2 and we may run into trouble as Software Package Y will not work properly anymore!
So we need to be careful when using “yum upgrade“, unless you have very low disk space, “yum update” is the safer option. Especially if you install software without using yum on your system.
Updating the Kernel
As we saw above, your distro is basically a combination of the Linux kernel and lots and lots of Software Packages. The above 2 commands, update and upgrade that we have been discussing don’t deal with the “kernel” part of your OS. So if we need to update the kernel how should we go about it?
This depends upon the particular distro you are using. This process also usually varies from version to version of your particular distro. If you are using RHEL or Fedora then you need to use dnf (the latest package management tool for RHEL and Fedora) instead of yum.
The commands to do that is
dnf -y update && dnf -y upgrade
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!