How to: Set Priotrities for YUM Repositories

Sometime when you have enabled many YUM Repositories like local repository, rpmforge, ATrpms for your server and it’s quite difficult to manage packages where you want that the package which you want to install too be searched on Local Repository first, then to CentOS Base, update and if it doens’t find the package here it will go for any other Third Party Repositories.

This Task can be done by setting up Priority for the Yum Repositories. Following are the steps to set Priorities for YUM Repositories

1) Install yum-priorities

The yum-priorities is used to enforce ordered protection of repositories, by giving priorities to repositories. Packages from repositories with a lower priority will never be used to upgrade packages that were installed from a repository with a higher priority. The priorities are also in effect when a new package is installed – if a package is in more than one repository, it will be installed from the repository with the highest priority. This plugin is particularly useful for anyone who uses one or more third-party repositories, as these repositories may update system files, which can potentially compromise the stability of your CentOS installation. This Package can be installed using following YUM Command.

[root@server ~]# yum install yum-priorities -y

**using option -y
with yum will allow yum to install package with taking permission from user.

2) Applying Priorities

Priorities for a Repository need to be added in .repo file. Following is the syntax for setting Priority


Here [NUM] will be the Priority. The Repository with higher priority will be used for installing any package. e.g. if you want your local repository should have highest priority than you can set highest priority for the same like below

name = CentOS $releasever – MyLocalRepo
baseurl = file:///opt/CENTOS/RPMS/

All other repositories will have lesser value as compared to Local Repository.

About: Mike

Milind Koyande loves to work on new technologies specially virtualization and troubleshoot server problems. I’m an avid photographer and love to spend my free time close to nature, trying to capture its glory on my camera.

2 thoughts on “How to: Set Priotrities for YUM Repositories”

This site uses Akismet to reduce spam. Learn how your comment data is processed.