Technology Encyclopedia Home >How to add new software repositories using YUM?

How to add new software repositories using YUM?

To add new software repositories using YUM (Yellowdog Updater Modified), you typically use the yum-config-manager tool or manually edit repository configuration files. Here’s how you can do it:

Using yum-config-manager:

  1. Install yum-utils if not already installed:

    sudo yum install yum-utils
    
  2. Add a new repository:

    sudo yum-config-manager --add-repo <repository_URL>
    

    For example, to add the EPEL (Extra Packages for Enterprise Linux) repository:

    sudo yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    

Manually Editing Repository Files:

  1. Create a new repository file:

    sudo vi /etc/yum.repos.d/<repository_name>.repo
    
  2. Add the repository details:

    [<repository_name>]
    name=<Repository Name>
    baseurl=<repository_URL>
    enabled=1
    gpgcheck=1
    gpgkey=<gpg_key_URL>
    

    For example, for the EPEL repository:

    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    baseurl=https://dl.fedoraproject.org/pub/epel/7/$basearch
    enabled=1
    gpgcheck=1
    gpgkey=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
    
  3. Save and exit.

Example:

To add the CentOS Vault repository manually:

  1. Create a new file:

    sudo vi /etc/yum.repos.d/centos-vault.repo
    
  2. Add the following content:

    [centos-vault]
    name=CentOS Vault
    baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
    
  3. Save and exit.

Recommended Cloud Service:

For managing repositories in a cloud environment, consider using Tencent Cloud's Tencent Container Registry (TCR), which provides a secure and reliable container image repository service. It supports integration with CI/CD pipelines and allows you to manage and distribute container images efficiently.