Yum Repository Management - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Community


Sometimes, you may have faced a problem showing that the package is not available in the repository. Though you came to know that the package needs to be installed using yum utility. Probably, you are facing this problem because the repository is not added to the yum repo list. In this tutorial, we will discuss how to add, enable, and disable a repository by using the yum-config-manager command.

Add Yum Repository

To add a new repository, you can add a URL in the repository section of the /etc/yum.conf file. Alternatively, you can add a .repo file in /etc/yum.repos.d/ directory as yum reads all the .repo files in this directory. Remember that the former technique is not recommended. If you want to add a new repository to your system and enable it, you have to run the following command as a root user:
#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 http://www.test.com/test.repo, type the following at a shell prompt:

# yum-config-manager --add-repo http://www.test.com/xyz.repo


Enable Yum Repository

After adding a repository, you have to enable it. So to enable a particular repository, you have to run the following command as a root user.

#yum-config-manager --enable repository_id

where repository_id indicates a unique name of the repository in the available repository list.

Alternatively, multiple repositories can be enabled by using matching expressions.

#yum-config-manager --enable matching_expression

For example, to enable repositories defined in the [xyz], [xyz-debuginfo], and [xyz-source]sections, you have to enter:

#yum-config-manager --enable xyz\*

When successful, the yum-config-manager --enable command displays the current repository configuration.



Disable Yum Repository

Similarly, a Yum repository can be disabled by executing the following command as a root user.

#yum-config-manager --disable repository_id

Similar to yum-config-manager --enable, you can use a matching expression to disable all matching repositories by executing the following command.

#yum-config-manager --disable matching_expression

Happy Exploring!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.