Like all Linux distros, it’s important to keep your CentOS system up to date in order to make sure that you have the latest security updates and newest features. Updating the system usually involves simply upgrading all installed packages to their latest versions. Every few years, there’s a new version of CentOS released, which requires a more involved update process to install.
In this article, we’ll cover updating a CentOS system on a per package basis and upgrading the entire operating system. This can be done via command line and GUI. Both methods will be shown in this guide, so you can pick whichever is easier for you.
The process for upgrading a CentOS system is a little different depending on which version you have installed. The latest version of Centos has moved to the dnf package manager. Previous to Centos 8, yum was the package manager used. Regardless of which version you’re running, we’ll show you the proper commands so you can update your system.
In this tutorial you will learn:
- How to update CentOS packages via command line
- How to update CentOS packages via GUI
- How to upgrade entire CentOS system
Category | Requirements, Conventions or Software Version Used |
---|---|
System | CentOS |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Update CentOS packages via command line
On CentOS 8 and newer versions, open a terminal and type the following command to check for available updates:
# dnf check-update
To install all of the updates shown, simply execute:
# dnf update
If there’s a specific package that you want to update, without updating everything else, you can specify it by name:
# dnf update httpd
On CentOS 7 and previous versions, the process is quite similar but you’ll be using the yum package manager. Use this command to check for available updates:
# yum check-update
Then, to install the packages shown:
# yum update
To update a specific package, specify it by name:
# yum update httpd
Update CentOS packages via GUI
This section will show you how to update CentOS via GUI. These instructions assume that you are using GNOME, the default desktop environment for CentOS.
- Get started by opening the activities menu and clicking on the software app.
- Navigate to the updates tab and make sure you click the refresh icon to fetch new updates.
- You can now update CentOS by clicking the download button. Note that this menu doesn’t allow you to select individual packages to update.
Upgrade entire CentOS system via command line
The command line instructions above are enough to keep applications up to date and upgrade CentOS to newer minor releases. However, upgrading to a new version will require some additional steps. This section of the guide will show how to upgrade older versions of CentOS to the current version, which is CentOS 8.
- Start by opening a terminal and enabling the EPL repository.
# yum -y install epel-release
- Install the
yum-utils
package.# yum install yum-utils
- Next, resolve RPM packages but make sure you choose the default option to keep your current version.
# yum install rpmconf # rpmconf -a
- Next, clean up all the packages your system no longer requires.
# package-cleanup --leaves # package-cleanup --orphans
- Install dnf, as it’s the new package manager for CentOS 8.
# yum install dnf
- Remove yum package mananger as it’s no longer used.
# dnf -y remove yum yum-metadata-parser # rm -rf /etc/yum
- Upgrade installed packages with dnf.
# dnf upgrade
- Updgrade the centos-release package from CentOS 7 to 8.
# dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm}
- Upgrade the EPL repository.
# dnf -y upgrade https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
- Remove the old kernel and conflicting packages.
# rpm -e `rpm -q kernel` # rpm -e --nodeps sysvinit-tools
- Launch the system upgrade to CentOS 8.
# dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
- Finally, install the new kernel core and extra packages for CentOS 8.
# dnf install -y kernel-core # dnf -y groupupdate "Core" "Minimal Install"
- Reboot to finalize the changes.
# reboot
Conclusion
In this guide, we saw the necessary steps to keep a CentOS system up to date, from both command line and GUI. We also saw how to perform a complete system upgrade to the latest release – CentOS 8. Remember that keeping your system up to date is important because it provides the latest security patches and bug fixes.