In this recipe, we will investigate the role of the Yellowdog Updater, Modified (YUM) package manager with regard to running a system update. Every once in a while, you may become aware of an update or may simply wish to discover if one exists. Applying patches and updates is a regular task for every server administrator, and an up-to-date system can help increase or ensure the security of your server as software bugs and vulnerabilities are found all the time and must be fixed promptly. In this recipe, you will learn how to achieve this with the help of YUM.
To complete this recipe, you will require a working installation of the CentOS 7 operating system with root privileges, a console-based text editor of your choice, and a connection to the Internet in order to facilitate the download of additional packages.
You can run this recipe, as often as required but it should be done frequently, based on a schedule of your own choosing in the full knowledge that on occasion, some updates may require a full system reboot:
yum check-update
yum -y update
-y
flag, the preceding command will now bypass the need to confirm the transaction summary, and your system will now undergo an immediate update process. When complete, you will be provided with a final report that identifies what dependencies have been installed and what packages have been updated.reboot
YUM is the default package management system for CentOS and part of its role is to automatically calculate what packages may require updating, what dependencies are required, and to manage the entire process of updating your system in a very simple way.
So, what have we learned from this experience?
We started the recipe by checking to see if any updates were available to our system using the yum
command with the check-update
option. In this way, YUM will now check a central repository to confirm if an update is applicable to our system. A repository is a remote directory or website that contains prepared software packages and utilities. YUM will use this facility to automatically locate and obtain the correct Red Hat Package Manager (RPM) and dependencies, and if an update is available, then YUM will respond accordingly with a full summary of what packages and dependencies are available. For this reason, YUM is a very useful tool, and without doubt its mechanism does serve to simplify the processes associated with package management, because it can talk to repositories and this saves us from having to find and install new applications or updates manually. If there are updates available, the output will show us exactly which packages are affected, then we can proceed to update the system by using YUM's update
parameter. In this instance, the preceding command includes the -y
flag. This is done in order to circumvent the need to agree with the transaction summary given, and to confirm that we have already agreed to make these updates after running the previous check. Otherwise, you would simply confirm the requests by using the Y key.
You can also use the update parameter to update single packages instead of the whole system by providing the package name like so: yum update package_name
. YUM will serve to ensure that all of the requirements for an application are met during installation, and it will automatically install the packages for any dependencies that are not already present on your system. However, and I am sure you will be pleased to hear this, if a new application has requirements that conflict with existing software, YUM will abort the process without making any changes to your system. If you want to automate the updating of your system using a specific time interval, you can install the yum-cron
package, which can be highly customized but is outside the scope of this book. To start after installation, use man yum-cron
.