How to Disable/Lock Certain Package Updates Using Yum Command

To Disable/Lock Certain Package Updates Using Yum Command

In this article we will discuss how to Disable/Lock Certain Package Updates Using Yum Command.


Disable/lock package permanently

Open the configuration file /etc/yum.conf and enter the following entry into this file.

In this configuration I have entered exclude option newly, this exclude option is used to block which package you want to block. You can enter single package or multiple packages into that exclude option for disabling installation and upgradation.
After done the setting in that configuration file save and close the file and try to install or update the package which was entered in that configuration file and see the result below

[root@linuxhelp Desktop]# yum update httpd
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Update Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                         | 5.0 kB     00:00     
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
.
.
.
remi-test                                                                                             | 2.9 kB     00:00     
updates                                                                                               | 3.4 kB     00:00     
No Packages marked for Update

Finally it shows " No packages marked for Update" now that particular package is successfully blocked.


Disable or lock the package temporarily

To disable or lock the package temporarily, use yum command with --exclude option or -x option. Now enter the package which you want to block after the --exclude option.

[root@linuxhelp Desktop]# yum --exclude vim update
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
-->  Package vim-enhanced-7.4.629-5.el6.x86_64 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
vim-enhanced-7.4.629-5.el6.x86_64 is installed.
Complete!

After exclude the package now update that package to see the result.

[root@linuxhelp Desktop]# yum update vim
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
.
.
.
* updates: centos.excellmedia.net
No Packages marked for Update

Now the update for that particular package is blocked.


Disable package updates using repository

Generally there will be many packages installed from any external source. You can stop the packages from being installed via adding a repository. There is another way to stop its up-gradation in future by editing .repo which was created in /etc/yum/repos.d

I have chosen epel repo and add exclude option enter which package want to block for install and update in future.

Now update the package which was excluded in epel.repo file

[root@linuxhelp Desktop]# yum update ajenti
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Update Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                         | 5.0 kB     00:00     
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
.
.
.
* updates: centos.excellmedia.net
epel                                                                                                  | 4.3 kB     00:00     
No Packages marked for Update

Now the package ajenti was blocked successfully.


Disable package update using versionlock

Install the version lock package, before you block the updates of particular package.

[root@linuxhelp Desktop]# yum install yum-versionlock
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
.
.
.
Updated:
yum-plugin-versionlock.noarch 0:1.1.30-37.el6                                                                              

Complete!

Once you installed version lock you should add that particular package into version lock for disabling update in future.

[root@linuxhelp Desktop]# yum versionlock add samba
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Adding versionlock on: 0:samba-3.6.23-30.el6_7
versionlock added: 1

Now check that particular package will be add into version lock by using below command.
[root@linuxhelp Desktop]# yum versionlock list samba
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI

0:samba-3.6.23-30.el6_7.*
versionlock list done

Now try to update that locked package and see the result.

[root@linuxhelp Desktop]# yum update samba
Loaded plugins: aliases, changelog, fastestmirror, kabi, presto, refresh-packagekit, security, tmprepo, verify, versionlock
Loading support for CentOS kernel ABI
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
.
.
.
* updates: centos.excellmedia.net
No Packages marked for Update

Again the result shows no packages for update

Tag : YUM Command
FAQ
Q
How can I search a Particular package?
A
Execute the following command to search the particular package:

# yum search vnc
Q
Can list the available packages?
A
Run the following command:

# yum list tigervnc
Q
I have daily cron job running with rpm --last command which helps me to trace the new packages installation. I want to stop this automatic updation of packages
A
add those packages to /etc/yum.conf
Q
I want to disable the auto update for all packages.
A
You can use exclude option in "/etc/yum.conf"
Q
How to check the repo name with yum?
A
Try "yum whatprovides packagename"