How to change the yum repository to a local source in C…

To change the yum repository of CentOS 7 to a local repository, you can follow these steps:

  1. First, open the terminal window of the CentOS 7 system.
  2. Log in to the system with root access.
  3. Back up the original yum repository configuration file.
  4. Create a backup copy of the CentOS-Base.repo file in the /etc/yum.repos.d/ directory.
  5. Open the yum repository configuration file using a text editor such as vi or nano.
  6. Open the file CentOS-Base.repo located in the directory /etc/yum.repos.d using the vi editor.
  7. Comment out the original yum repository configuration and add a local repository configuration.
  8. [base]
    name=CentOS-$releasever – Base
    baseurl=file:///path/to/local/repo
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    [updates]
    name=CentOS-$releasever – Updates
    baseurl=file:///path/to/local/repo
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    [extras]
    name=CentOS-$releasever – Extras
    baseurl=file:///path/to/local/repo
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    [centosplus]
    name=CentOS-$releasever – Plus
    baseurl=file:///path/to/local/repo
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    [contrib]
    name=CentOS-$releasever – Contrib
    baseurl=file:///path/to/local/repo
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  9. In the aforementioned configuration, replace /path/to/local/repo with the path to your local source.
  10. Save and close the file.
  11. Clear the yum cache.
  12. clear all package cache
  13. Regenerate the yum cache.
  14. refresh the yum cache

You have now successfully switched the yum source of CentOS 7 to a local source. You can use the yum command to install and update packages.

bannerAds