RHEL7 initial repo setup

Author: | Posted in distro No comments

The default Red Hat installation doesn’t activate any official yum repositories automatically, so this shows how to do that. I am using the Red Hat Developer subscription which allows one to download and use RHEL for personal purposes (i.e. non-comercial).
After the OS installation and reboot no repos are available (ls -l /etc/yum.repos.d confirms that). In order to add the Red Hat repos, the system has to be registered and subscribed. There are several ways to do that, but I find it easier to do the following:

1. Register the system

subscription-manager register


2. Auto attach a valid subscription

subscription-manager attach

The first command asks for credentials to login to Red Hat Customer Portal and the second one auto-attaches (the ‘auto’ flag is default) an active subscription which is suitable for the system.
Specific subscriptions can be assigned by using their pool ID:

subscription-manager list --available --all | grep "Pool ID"
subscription-manager attach --pool=$POOL_ID

3. Enable repos

The Red Hat Developer subscription entitles one to use various RedHat repos. A full list is returned with:

subscription-manager repos --list

To filter out unwanted repos the output can be piped to exclude key words e.g.

subscription-manager repos --list | grep "Repo ID" | egrep -vi 'source|beta|debug|atomic'

A selection of repos can be enabled using:

subscription-manager repos --enable=rhel-7-server-extras-rpms --enable=rhel-7-server-optional-rpms --enable=rhel-server-rhscl-7-rpms --enable=rhel-7-server-thirdparty-oracle-java-rpms

The yum output confirms the repos have been enabled and are ready to use:

yum repolist

Hope this helps!

Add Your Comment

Your email address will not be published. Required fields are marked *

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