Updated April 15, 2023
Introduction to Centos Repositories
In the Linux environment, there are multiple reasons to install or configure the repositories like packages installation, to get the data from any other location, etc. But ideally, we are configuring or installing the repositories for the packages installation. There are multiple ways to install the packages in the CentOS operating system. In the CentOS ecosystem, we are generally following two methods like yum and rpm. As per the requirement or usage, we need to choose any one of these methods and install the packages. But before that, we need to configure the repository correctly. While configuring the repository, we need to follow some basic protocol or rules then only we are able to use the repositories in the CentOS operating system.
As such, there is no specific syntax available for the repository configuration. As per the requirement, we can configure the repository for a specific use or package installation. Generally, we are configuring the repositories at the specific path like “/etc/yum.repos.d”. As per the requirement or application use case, we need to follow some set of rules while configuring the CentOS repository.
Sample method how to configure or edit the repository file : vi /etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo: As per the above technique, we can use any editor like vi, vim, nano to edit the file. Here, we need to add the base name, repository name, baseurl, gpgcheck status, etc.
How Centos repositories Works?
In the CentOS environment, we can use the system repo or own create repo. In the repo list, we need to add the repo name, baseurl, gpgcheck, enable option, etc. Once we have created the repository, it will help to install the packages from the baseurl. If you want to use the reposync command then we can use the different option with it. Below are the lists of options that are compatible with the “reposync” command.
1. -g – We can use this option when we need to uninstall or remove packages on the CentOS environment (We are using this when the GPG check fails)
2. -l – It will help for the yum plugin
3. -d – It will help to remove or delete the local packages those are no longer exist in the current working repository
4. -m – It will help to download the comps.xml files. It will normally bundle the groups of packages by function
a. –repoid – Here we need to specify the repository ID
b. –newest-only – It will help to install or download the latest package version. It will also help to manage the size of the repository
c. –download-metadata – It will help to download the non-default metadata
d. –download-path – It will help to specify the location where you need to save the packages
Examples to understand Centos repositories
Centos repositories: List all the Repositories in the Environment
We are able to list out the number of repositories which is available in the CentOS environment.
As per the above command, we are getting the list of repositories which is available in the CentOS environment. In the output window, we are getting different information like repo id, repo name and status. In some cases, we are not getting the status i.e. the status column value is zero. If we will get the status column value is zero then we can consider that the repo is not configured correctly and we need to check it one more time.
Centos repositories: How to check enable Repository
In the CentOS environment, we are having the functionality to get the status of the enabled repositories.
yum repolist enabled
As per the above command, we are able to get the status of enabling repositories which is present in the current working environment.
Centos repositories: How to check disabled repositories
In the CentOS environment, we are having the functionality to get the status of the disabled repositories. It will help to analyze the repository and able to take the necessary action on the same.
yum repolist disable
As per the above command, we are getting the list of repositories that are currently disabled in the environment. As per the requirement, if we need to enable any of the repositories then we can also enable it.
Note: The below screenshot output is the minimal installation of CentOS.
Screenshot 1 (a)
Screenshot 1 (b)
Centos repositories: Configure New Repository and List it
As per the requirement, we can configure the own repository in the CentOS environment.
Below is the content of the “own_mariadb.repo” file
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
Here, we are configuring the own MySQL repo. It will help to download the MariaDB packages from the internet. In the above file “/etc/yum.repos.d/own_mariadb.repo”, we are adding a few lines to install the MariaDB packages from the internet.
Screenshot 2 (a)
Screenshot 2 (b)
Centos repositories: enable and disable status all the repositories
In the CentOS ecosystem, we are having the functionality to the status of enabling as well as disabled repositories. But if we need to check all the repository status in the same windows then we can also check it.
yum repolist all
As per the above command, we are able to list out the entire repository in the CentOS environment. Here, it is very easy to find the status of the entire repository. On the same working window, we are getting the status information i.e. the disabled or enabled status. The enabled repository should be visible in green color code. The disabled repository should be visible in red color code.
Screenshot 3 (a)
Screenshot 3 (b)
We have seen the uncut concept of the “Centos repositories” with the proper example, explanation, and command with different outputs. By default, we will get the basic operating system packages repository in the CentOS environment. As per the requirement, we can also configure our own repository. In the CentOS environment, we can get the status of the repository.
We hope that this EDUCBA information on “Centos Repositories” was beneficial to you. You can view EDUCBA’s recommended articles for more information.