May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

How to add a new yum repository

News YUM Recommended Links Reference Yum's repository system How to add a new yum repository Proxy configuration
EPEL repository How to Enable EPEL Repository Yum Plugins How to download RPMs with yum Download Dependencies for a RPM Red Hat RPM hell
Smart Pirut Yast Horror Stories Unix History Humor Etc

Road to hell is paved with good intentions. This saying is fully applicable to RHEL repositories.

From Fedora project 4.3.5. Adding, Enabling, and Disabling a Yum Repository Section 4.3.2, “Setting [repository] Options” described various options you can use to define a Yum repository. This section explains how to add, enable, and disable a repository by using the yum-config-manager command. For example

yum-config-manager --add rhel-7-server-optional-rpms
yum-config-manager --add rhel-7-server-supplementary-rpms


Adding a Yum Repository

To tell your server which repository to use, you need to create a file with a name that ends in .repo in the directory /etc/yum.repos.d

To define a new repository, you need to add a .repo file in the /etc/yum.repos.d/ directory.  It can be created manually or copied from other server which already has  this repository subscribed.

To add such a repository to your system and enable it automatically, you need to use the command yum-config-manager as root . This operation is called a subscription to the repository and the command to use in not yum, but  yum-config-manager For example

yum-config-manager --add rhel-7-server-optional-rpms
yum-config-manager --add rhel-7-server-supplementary-rpms


For CentOS all the necessary repo files are created during the installation. The default content the /etc/yum.repos.d/ directory is as following:

[0]d620@ROOT:/etc/yum.repos.d # ll
total 32K
-rw-r--r--. 1 root root 1.7K Nov 23 08:16 CentOS-Base.repo
-rw-r--r--. 1 root root 1.3K Nov 23 08:16 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23 08:16 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23 08:16 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23 08:16 CentOS-Media.repo
-rw-r--r--. 1 root root 1.3K Nov 23 08:16 CentOS-Sources.repo
-rw-r--r--. 1 root root 5.6K Nov 23 08:16 CentOS-Vault.repo
For RHEL7 self-support  the list is different:
b33:/etc/yum.repos.d # ll
total 88
-rw-r--r--.   1 root root 70660 Jan 25 08:18 redhat.repo

Each file in  /etc/yum.repos.d directory defines a set of repositories from a common provider and consists of section delineated with labels in square brackets. For example  [rhel-7-server-supplementary-rpms]  The .repo file can contain multiple repositories. In this vase there are multiple section with each section starting with a label that identifies the specific repository.

After the label there are three main fields:

There are multiple labels in this file but  the most important is the label [base]. In CentOS it defines mirrorlist and if you do not have a good mirror in vicinity you might have trouble with CentOS update. Mirrors for CentOS are provided voluntarily and mainly by educational institutions which often do not have great bandwidth to begin with.  So patching servers at night is a better deal for CentOS.

You can replace mirrorlist with the best repository in your vicinity. That requires some research, but if you have difficulties accessing repositories via mirrorlist (for example due to the proxy)  it pays off. 

Sometimes repositories prevent patching (this is often the  case with R rpms installed from EPEL) you can simply disable them via command

yum-config-manager --disable repository...

 and after patching is done reenable

yum-config-manager --enable repository...

You can always check the results with the command

Be careful when using untrusted software sources

Obtaining and installing software packages from unverified or untrusted software sources constitutes a potential security risk, and could lead to security, stability, compatibility maintainability issues.
yum-config-manager --add-repo repository_url
…where repository_url is a link to the .repo file. For example, to add a repository located at, type the following at a shell prompt:
# yum-config-manager --add-repo
Loaded plugins: langpacks, presto, refresh-packagekit
adding repo from:
grabbing file to /etc/yum.repos.d/example.repo
example.repo                                             |  413 B     00:00
repo saved to /etc/yum.repos.d/example.repo

Enabling a Yum Repository

To enable a particular repository or repositories, type the following at a shell prompt as root:

yum-config-manager --enable repository

…where repository is the unique repository ID (use yum repolist all to list available repository IDs). For example

yum-config-manager --enable rhel-6-server-extras-rpms


subscription-manager repos --enable rhel-6-server-extras-rpms

Alternatively, you can use a glob expression to enable all matching repositories:

yum-config-manager --enable glob_expression
For example, to disable repositories defined in the [example], [example-debuginfo], and [example-source]sections, type:
~]# yum-config-manager --enable example\*
Loaded plugins: langpacks, presto, refresh-packagekit
============================== repo: example ==============================
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6Server
baseurl =
cache = 0
cachedir = /var/cache/yum/x86_64/6Server/example
[output truncated]
When successful, the yum-config-manager --enable command displays the current repository configuration.

Disabling a Yum Repository

To disable a Yum repository, run the following command as root:
yum-config-manager --disable repository
…where repository is the unique repository ID (use yum repolist all to list available repository IDs). Similarly to yum-config-manager --enable, you can use a glob expression to disable all matching repositories at the same time:
yum-config-manager --disable glob_expression
When successful, the yum-config-manager --disable command displays the current configuration.
Top updates

Bulletin Latest Past week Past month
Google Search


Old News ;-)

Howto Add a new yum repository to install software under CentOS - Redhat Linux - nixCraft

July 18, 2007 | NIX Craft | 12 comments

Understanding yum repository

yum repository configured using /etc/yum.conf file. Additional configuration files are also read from the directories set by the reposdir option (default is /etc/yum.repos.d and /etc/yum/repos.d.

RPMforge repository

Usually repository carries extra and useful packages. RPMforge is one of such repository. You can easily configure RPMforge repository for RHEL5 just by running following single RPM command:
# rpm -Uhv
For 64 bit RHEL 5 Linux, enter:
# rpm -Uhv

Now you can install software from RPMforge.

How do I install 3rd party repository manually?

Let us say you would like to install 3rd party repository from Create a file called foo:
# cd /etc/yum.repos.d
# vi foo

Append following code:
name=Foo for RHEL/ CentOS $releasever - $basearch

Save and close the file.


Also you need to import the gpg key for the repository as follows:
# rpm --import

Now you are ready to install software from foo repository. For further information refer to yum.conf man page:
$ man yum.conf
$ man yum

Hope this tip will help you to configure repository as and when required.

See also:

Howto Setup yum repositories to update or install package from ISO CDROM Image

How to Add the RPMforge Repository in RHEL/CentOS 5/6

RPMforge is a third party RPM repository for Red Hat Enterprise Linux or CentOS. Adding the RPMforge repository will give you access to an extensive library of precompiled binaries. This article describes how to add the RPMforge repository in Red Hat Enterprise Linux or CentOS 5 or 6.

Adding RPMforge to Yum

The rpmforge repo package can be downloaded from the site below.

1. Launch Firefox and go to Click on the package appropriate for your version of Red Hat Enterprise Linux or CentOS.

2. Choose Open with Software Installer (default) and click Ok.

3. The Installing packages window will appear. Click Apply to proceed.

4. Finally click Ok.

Lowering the RPMforge priority

Lowering the priority of the RPMforge repository will ensure that the base packages provided by RHEL/CentOS will not be replaced by a newer version from RPMforge.

1. Install the Yum priorities package using the command below.
yum install yum-priorities
2. Edit the file /etc/yum.repos.d/rpmforge.repo and add the line below.
3. Test your configuration using the command below. You should see a priority protections message in the output.
yum check-update

Visit the forum to ask for help or to give a comment.

Posted on 6/12/2009 and last updated on 8/8/2011
Filed under CentOS 5 , CentOS 6 , Red Hat Enterprise Linux 5 , Red Hat Enterprise Linux 6 , System Administration