Install fresh copies of centos 7 base repos

Shafiq picture Shafiq · Apr 25, 2017 · Viewed 37.5k times · Source

I am using centos 7. During some testing, I accidentally removed all files in yum.repo.d. Is there a way, to download and configure all basic repos in centos 7

Answer

iamauser picture iamauser · Apr 26, 2017

Assuming you are running CentOS-7.3, you can get back the repo files the following way,

# ReInstall the centos-release rpm
~]#  rpm -Uvh --force \
     http://mirror.centos.org/centos-7/7/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm

# Clean YUM cache
~]# yum clean all

# Try an update
~]# yum update

centos-release RPM contains all the repo files,

~]#  rpm -qlp \
     http://mirror.centos.org/centos-7/7/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm 2>/dev/null | grep repo
/etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/CentOS-CR.repo
/etc/yum.repos.d/CentOS-Debuginfo.repo
/etc/yum.repos.d/CentOS-Media.repo
/etc/yum.repos.d/CentOS-Sources.repo
/etc/yum.repos.d/CentOS-Vault.repo
/etc/yum.repos.d/CentOS-fasttrack.repo