Howto: Install New Yum Repositories in Fedora/Redhat

Please note the below also works for Centos.Redhat Logo

There are a acouple of ways of adding repositories in Fedora/Red Hat. All repositories are stored in the /etc/yum.repos.d directory in Fedora/Redhat.
For well known repositories it is best and more simpler to install a .rpm package to add the repositories to your system. Such as below, which will add the livna-release repositories to your system. You would substitute the URL with one you have found on the internet.

rpm -Uvh

For repositories that need to be installed manually it is a little bit different we have to create a .repo file as found in the /etc/yum.repos.d directory. For the below example lets make it that you found and want to install a repository from following would be the steps needed to carry this out:

# cd /etc/yum.repos.d 
# vi samplerepo.repo

Append the following in the samplerepo.repo file.

name=Samplerepo $releasever - $basearch

Save and close the file.

See below information on the options used in the .repo file. Where,

  • [samplerepo] – The Repository name
  • name=Samplerepo $releasever – $basearch – A human readable description of the repo.
  • 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 enabled to 0
  • gpgcheck=1 – Security feature, use GPG key
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-samplerepo-$basearch – GPG license location

You also need to import the GPG keys for the repository. The GPG key is used as a signature, so that you and the system can check the authenticity of the repository. As follows is how to get the GPG key:

# rpm --import

Your repository should now be installed. If you have enabled the repository you can check with:

# yum repolist enabled

If you have it disabled, you can check with:

# yum repolist disabled

Be First to Comment

    Leave a Reply