Centos7 set up yum source

Why modify the yum source?

Because the default yum source download speed is very slow, we need to modify the yum source. I use Alibaba Cloud’s yum source.

environment

Virtual machine: VirtualBox 7.0.4

Operating system: CentOS 7 x86_64

View the default yum source

cd /etc/yum.repos.d

Insert image description here

Copy all default yum sources listed for backup and copy them to the /data directory.

cp -r /etc/yum.repos.d /data

When using the cp command to copy a directory, the parameter -r must be used. Copy all files in the current directory /etc/yum.repos.d to the new directory /data.

After the copy is completed, we go to the /data directory to check whether the copy was successful.

cd /data
ll
ls

Use the ll or ls command to view the directory contents

Insert image description here

Clear the /etc/yum.repos.d directory

Following the previous step, we return to the /etc/yum.repos.d directory and clear the current directory, and then check whether the clearing is successful.

cd /etc/yum.repos.d
rm -rf *
ls

Insert image description here

rm -rf * delete all files and directories in the current directory

rm options:

  1. -r deletes all contents of the directory one by one
  2. -f Even if the document content is read-only, delete it directly without confirmation.

Check operating system version

Check the Centos version, and then we can download the corresponding yum source configuration file from the Alibaba Cloud website.

rpm -qi centos-release

Insert image description here

Go to the Alibaba Cloud mirror station to find the corresponding file, address: https://mirrors.aliyun.com/repo/

Insert image description here

Use wget to download the configuration file

Wget is a tool for downloading files. Centos has this tool installed by default. If you don’t have this tool, use the following command to install it

yum install wget

Download the configuration file and rename it to aliyun-Base-7.repo

wget -O /etc/yum.repos.d/aliyun-Base-7.repo https://mirrors.aliyun.com/repo/Centos-7.repo

Insert image description here

After the download is successful, we need to clear the yum cache

yum clean all
yum makecache

Insert image description here

At this point, the yum source has been successfully set up.

Guess you like

Origin blog.csdn.net/Zhang_YingJie/article/details/130537576