Disable Updates of a Specific Package in RHEL/Fedora/CentOS

Disable Updates Of A Specific Package In RHELFedoraCentOS

DNF is the default package manager in RHEL, Rocky Linux, Alma Linux, Fedora, and CentOS along with the YUM package manager. Upgrading your distribution is very simple using these package managers. However, we don’t always want to update certain packages like MySQL, PHP, Apache Server (HTTP), and other important applications which will certainly break many features on our server.

This is why it is always recommended to stop those packages from updating. In this article, we will be modifying our yum.conf and dnf.conf files present in /etc/yum/ and /etc/dnf/ directories, respectively.

Modify your DNF and yum conf files

Open the yum.conf file in your choice of text editor (vim or nano) by typing the following lines in the terminal :

# For Vim users
sudo vim /etc/yum.conf

# For Nano editor users
sudo nano /etc/yum.conf

If you’re using Vim editor, then press ‘i’ on your keyboard to get into the insert mode, and add the following lines at the end of the file:

# Exclude following Packages Updates
exclude=httpd php mysql

If you are using vim editor, then press the escape key and then type :wq to save and exit. On Nano editor, press Ctrl+O to save the file and press Ctrl+X to exit. Now, modify the dnf.conf file by opening it in a text editor as:

# For Vim users
sudo vim /etc/dnf/dnf.conf

# For Nano editor users
sudo nano /etc/dnf/dnf.conf

And again add the following lines at the end of the file:

# Exclude following Packages Updates
exclude=httpd php mysql
Edit Conf Files To Exclude Packages From Updating
Edit conf Files To Exclude Packages From Updating

Again, vim users can press the escape to get out of insert mode and press :wq to save and exit and nano users can press Ctrl+O and Ctrl+X to save and exit.

Check if you have disabled the updates

And that’s it, now test if this modification works, let’s try updating an excluded application.

sudo dnf update httpd
We have successfully disabled updates of httpd package
We have successfully disabled updates of httpd package

Summary

Do not forget to upgrade these packages once in a while, though, whenever the server is experiencing downtime because old packages get deprecated over time and new software packages also have important security bug fixes.

References

DNF official documentation – Fedora