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
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
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
rm -rf * delete all files and directories in the current directory
rm options:
- -r deletes all contents of the directory one by one
- -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
Go to the Alibaba Cloud mirror station to find the corresponding file, address: https://mirrors.aliyun.com/repo/
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
After the download is successful, we need to clear the yum cache
yum clean all
yum makecache
At this point, the yum source has been successfully set up.