A repository is a storage location that contains software packages and metadata.
YUM-based systems (RHEL, CentOS, Rocky Linux, AlmaLinux) use repositories to:
YUM repositories are defined in configuration files located at:
/etc/yum.repos.d/
Each repository is stored as a .repo file.
List all enabled and disabled repositories.
yum repolist all
Ensure YUM utilities are installed.
sudo yum install -y yum-utils
Create a new repository file.
sudo vi /etc/yum.repos.d/example.repo
Add the following content:
[example-repo]
name=Example YUM Repository
baseurl=http://repo.example.com/centos/7/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=http://repo.example.com/RPM-GPG-KEY-example
Automatically add and enable a repository.
sudo yum-config-manager --add-repo http://repo.example.com/example.repo
Import the repository GPG key to verify package authenticity.
sudo rpm --import http://repo.example.com/RPM-GPG-KEY-example
Download repository metadata.
sudo yum clean all
sudo yum makecache
Confirm the repository is enabled and available.
yum repolist
Install a package provided by the newly added repository.
sudo yum install example-package
Temporarily enable or disable repositories.
sudo yum-config-manager --enable example-repo
sudo yum-config-manager --disable example-repo
Delete the repository configuration file.
sudo rm -f /etc/yum.repos.d/example.repo
Repository management in YUM-based Linux systems involves adding, verifying, enabling, and maintaining software sources. Proper repository configuration ensures secure, reliable, and efficient software installation and system updates.