How To Install Updates On CentOS 7.
In this tutorial, we will show you how to manually update system packages on CentOS 7. The same instructions apply for CentOS 6.
Updating Packages on CentOS
RPM is a packaging system used by Red Hat and its derivatives such as CentOS.
Yum is the default package manager tool in CentOS. It is used to install, remove, download, query and update packages from the official CentOS repositories as well as other third-party repositories.
Before running the update you can check for available updates using the following command:
The output will contain a list of all packages that are available for update:
To update a single package use the yum install command followed by the name of the package you want to update. For example, to update only the curl package you would run:
Yum will give you a summary of the packages that will be updated and prompt you for confirmation. Answer y and the packages will be updated.
To update all packages use the yum update command:
The command will update the repositories and give you a list of all packages that can be updated. When prompted type y to continue.
Prevent Packages From Being Updated
Sometimes you may want to restrict a package from being updated to a newer version. The Yum plugin versionlock allows you to lock packages to a specific version.
The plugin is not installed by default so first, you’ll need to install it:
During the installation two configuration files will be created on your system, stored in the /etc/yum/pluginconf.d directory. The configuration file versionlock.conf and the file versionlock.list containing the locked packages. By default, no packages are listed in this file.
To lock a version of a package you can either manually add the package name in the file or use the yum versionlock command followed by the package name. For example, to prevent all PHP packages (all packages starting with “php-”) from being updated you would run:
This will lock the PHP packages to the current version.
Viewing Yum logs
The history of the packages installed and updated with yum is logged in the /var/log/yum file. You can view the latest records using the cat or tail command:
The output will include records about the packages installations and updates:
Installing updates and keeping your CentOS system up-to-date is pretty straightforward but if you manage multiple CentOS machines, it may be time-consuming and sometimes you may overlook an important update. The best option is to set up automatic updates.