4 Ways to Disable/Lock Certain Package Updates Using Yum Command

[‘

n

Package Manager is software which allows a user in case of installation of new software, up-gradation of system, or updating any specific software and such sorts of things. In case of Linux based systems wherein one software has lots of dependencies which are required to be present on system for a complete installation of that software, such software’s like package manager become a much needed tool on every system.

n

Disable Lock Certain Package Updates Yum
Disable Lock Certain Package Updates with Yum

n

Each Linux Distribution ships with its default package manager for above stated functionalities, but of all these most found ones are: yum on RHEL and Fedora systems (where it is being currently replaced with DNF from Fedora 22+ onwards) and apt from Debian.

n

If you’re looking for APT tool to block or disable certain specific package updates, then you should read this article.

n

n

Dnf or Danified yum is replacing yum on Fedora systems which is another one in our list. If explored properly, these Package Managers can be used for following functionalities:

n

    n

  1. Installing new software from the repository.
  2. n

  3. Resolve dependencies of the software by installing those dependencies before installing the software.
  4. n

  5. Maintaining database of dependencies of each software.
  6. n

  7. Downgrade version of any existing software.
  8. n

  9. Upgrading the kernel version.
  10. n

  11. Listing packages available for installation.
  12. n

n

We’ve already covered detailed articles separately on each individual package managers with practical examples, you should must read them to control and manager package management in your respective Linux distributions.

n

Read Also:

n

    n

  1. Mastering Yum Command with this 20 Practical Examples
  2. n

  3. 27 DNF Commands to Manage Packages in Fedora 22+ Versions
  4. n

  5. Learn 25 APT Commands to Manage Ubuntu Packages
  6. n

n

In the article, we will see how to lock/disable certain package updates using Yum package manager in RHEL/CentOS and Fedora systems (applicable till Fedora 21, later newer Fedora version ships with dnf as default package manager).

n

Disable/Lock Package Updates using Yum

n

Yellow dog Updater, Modified (yum) is package management tool in RedHat based distributions such as CentOS and Fedora. Various strategies used to Lock/Disable Package Updates using Yum are discussed below:

n

1. Permanently Disable Package for Install or Update

n

1. Open and edit the yum.conf file, which is located in /etc/yum.conf or in /etc/yum/yum.conf.

n

It looks like below:

n

[main]rncachedir=/var/cache/yum/$basearch/$releaseverrnkeepcache=0rndebuglevel=2rnlogfile=/var/log/yum.logrnexactarch=1rnobsoletes=1rngpgcheck=1rnplugins=1rninstallonly_limit=5rnbugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yumrndistroverpkg=centos-releasern...rn

n

Here, to exclude certain package from installation or up-gradation, you just need to add exclude variable along with name of package you wish to exclude. For example, if I want to exclude all the python-3 packages from getting updated, then I will just append following line to yum.conf:

n

exclude=python-3*rn

n

For more than one package to exclude just separate their names by space.

n

exclude=httpd php rn

n

[main]rncachedir=/var/cache/yum/$basearch/$releaseverrnkeepcache=0rndebuglevel=2rnlogfile=/var/log/yum.logrnexactarch=1rnobsoletes=1rngpgcheck=1rnplugins=1rninstallonly_limit=5rnbugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yumrndistroverpkg=centos-releasernexclude=python-3*        [Exclude Single Package]rnexclude=httpd php        [Exclude Multiple Packages]rn...rn

n

Note: to include these packages, ignoring entries in yum.conf, use “-disableexcludes” and set it to all|main|repoid, where ‘main’ are those entered in yum.conf and ‘repoid’ are those whose exclusion is specified in repos.d directory, as explained later on.

n

Now let’s try to install or update the specified packages and see the yum command will disable them installing or updating.

n

# yum install httpd phprnrnLoaded plugins: fastestmirror, langpacks, versionlockrnLoading mirror speeds from cached hostfilern * base: mirror.nbrc.ac.inrn * epel: mirror.wanxp.idrn * extras: mirror.nbrc.ac.inrn * updates: mirror.nbrc.ac.inrnNothing to dorn

n

# yum update httpd phprnrnLoaded plugins: fastestmirror, langpacks, versionlockrnLoading mirror speeds from cached hostfilern * base: mirror.nbrc.ac.inrn * epel: mirror.wanxp.idrn * extras: mirror.nbrc.ac.inrn * updates: mirror.nbrc.ac.inrnNo packages marked for updatern

n

2. Temporarily Disable Package for Install or Update

n

2. Above was a permanent solution to exclude a package as unless file is edited, that package won’t get updated. Here is a temporary solution for this also. Just at the time when you go for any update, use -x switch in yum command to exclude package which you do not want to update, like:

n

# yum -x python-3 updatern

n

The above command will update all the packages whose updates are available, excluding python-3 on your system.

n

Here, for excluding multiple packages, use -x multiple times, or separate package names with ',' in a single switch.

n

# yum -x httpd -x php updaternORrn# yum -x httpd,php updatern

n

3. Using --exclude switch works same as -x, just need to replace -x with –exclude and pass ',' separated list of package names to it.

n

# yum --exclude httpd,phprn

n

3. Disable Package Updates using Repository

n

4. For any package installed from any external source via adding a repository, there is another way to stop its up-gradation in future. This can be done by editing its .repo file which is created in /etc/yum/repos.d/ or /etc/yum.repos.d directory.

n

Add the exclude option with the package name in the repo. Like: to exclude any package say wine from epel repo, add the following line in epel.repo file:

n

[epel]rnname=Extra Packages for Enterprise Linux 7 - $basearchrn#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearchrnmirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearchrnfailovermethod=priorityrnenabled=1rngpgcheck=1rngpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7rnexclude=winern

n

Now try to update the wine package, you will get error like shown below:

n

# yum update winernrnLoaded plugins: fastestmirror, langpacks, versionlockrnepel/x86_64/metalink                                    | 5.6 kB     00:00     rnLoading mirror speeds from cached hostfilern * base: mirror.nbrc.ac.inrn * epel: mirror.wanxp.idrn * extras: mirror.nbrc.ac.inrn * updates: mirror.nbrc.ac.inrnNo Match for argument: winernNo package wine available.rnNo packages marked for updatern

n

4. Disable Package Update Using versionlock Option

n

5. Another way in yum to mask the version of any package thus making it unavailable for up-gradation, is to use versionlock option of yum, but to do this, you must yum-plugin-versionlock package installed on the system.

n

# yum -y install yum-versionlockrn

n

For example, to lock the version of package say httpd to 2.4.6 only, just write following command as root.

n

# yum versionlock add httpdrn

n

Sample Output

n

Loaded plugins: fastestmirror, langpacks, versionlockrnAdding versionlock on: 0:httpd-2.4.6-40.el7.centosrnversionlock added: 1rn

n

To view locked packages, use the following command will list the packages which have been version locked.

n

# yum versionlock list httpdrn

n

Sample Output

n

Loaded plugins: fastestmirror, langpacks, versionlockrn0:httpd-2.4.6-40.el7.centos.*rnversionlock list donern

n

Conclusion

n

These are a few tips which will help you Disable/Lock Package updates using yum package manager. If you have any other tricks to do the same things, you can comment them with us.

n

‘]