Howto: Add a new yum repository to install software under CentOS / Redhat Linux

by on July 18, 2007 · 12 comments· LAST UPDATED July 18, 2007

in , ,

CentOS / Fedora Core / RHEL 5 uses yum for software management. Yum allows you to add a new repository as a source to install binary software.

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.


  • [foo] : Repository name i.e. The [main] section must exist for yum to do anything.
  • name=Foo for RHEL/ CentOS $releasever - $basearch : A human readable string describing the repository name
  • baseurl=$releasever/$basearch/ : Must be a URL to the directory where the yum repository’s ‘repodata’ directory lives
  • enabled=1 : Enabled or disabled repo. To disable the repository temporarily, set the enabled to 0
  • gpgcheck=1 : Security feature, use GPG key
  • gpgkey= : GPL file location

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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 12 comments… read them below or add one }

1 Mace Moneta July 18, 2007 at 12:59 pm

You might also be interested in repoman, which is also available in the Fedora repositories.


2 nixCraft July 18, 2007 at 7:18 pm

Thanks for sharing repoman :)


3 Servlet May 4, 2009 at 10:15 am

Quite useful, this is what I was look for, You save a lots of time.



4 Robert August 7, 2009 at 5:18 pm

Make sure you append.repo to foo. Thanks!


5 Blake November 12, 2009 at 11:45 pm

Looks like they moved the file to another directory. I needed to use this to get it to work…

rpm -Uhv


6 etech3 December 15, 2009 at 5:46 pm

The new link above is for 86_64 bit I think. where’s the new link for 32 bit?


7 Linux Person April 29, 2010 at 6:57 pm

The command line to add the 32bit RH el5 repository for yum is;

rpm -Uhv

as of today.

(It would be nice if we could signal the editors to update the command line above to reflect these updates… ;)



8 Linus Torvalds July 18, 2010 at 12:51 pm

Hi Linux fans,
for those who get an error while trying to retrieve the rpm from the address mentioned in this wonderful post, here’s the new one:

Good luck in your Linux endeavors, I hope you will all find it useful in your lives.



9 Kyle Buser October 19, 2011 at 4:09 pm

Here’s a complete listing of the rpmforge releases.
Just go here and find the appropriate one for your box.


10 oyun July 12, 2012 at 1:33 pm

thank you, it’s very useful


11 Carl April 18, 2013 at 9:05 am

Hi Linux fans
I’m using Centos 6 :



12 A May 19, 2014 at 10:12 am

Automation :
$ wget http://foo/bar.repo
# cp bar.repo /etc/yum.repods.d/
# rpm –import $(sed -n -e ‘/gpgkey/ s/.*\= *//p’ bar.repo)

Taken from here :


Leave a Comment

Tagged as: , , , , , , , ,

Previous post:

Next post: