Location>code7788 >text

Setting up yum sources for centos

Popularity:667 ℃/2024-10-27 21:44:27

Reprinted with attribution:

On CentOS, yum comes with it. yum (Yellowdog Updater, Modified) is a package manager widely used in CentOS and other Red Hat-based Linux distributions. It is designed to simplify the process of installing, updating, and uninstalling software packages, while providing convenient source management and dependency resolution.

On CentOS systems, yum is pre-installed by default and is located in the/etc//directory. The yum repository configuration file in this directory must end with ".repo". By default, CentOS automatically generates a local yum mount name and a few included web yum sources. However, these self-contained web yum sources are usually foreign websites, so they may be slow or inaccessible when accessed domestically. In order to solve this problem, users can change the yum source by themselves to some well-known domestic yum sources, such as Tsinghua source, Ali source, and so on.

The use of yum is very simple, through the command line to complete a variety of package management operations. For example, you can use the command "yum install [package_name]" to install a specified package; "yum update [package_name]" to update a specified package; "yum remove [package_name]" to remove a specified package; "yum remove [package_name]" to remove a specified package; "yum remove [package_name]" to remove a specified package; "yum remove [package_name]" to remove a specified package. package; use the "yum remove [package_name]" command to remove the specified package; use the "yum search [package_name]" command to search for the specified package in the repository. package in the repository, etc.

The following common ones can be usedYUMsources, which typically have faster speeds and higher availability:

Aliyun

[aliyun]
name=Aliyun mirrors
baseurl=http:///centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http:///centos/RPM-GPG-KEY-CentOS-7

Tencent Cloud

[tencent]
name=Tencent mirrors
baseurl=http:///centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http:///centos/RPM-GPG-KEY-CentOS-7

Huawei Cloud

[huawei]
name=Huawei mirrors
baseurl=http:///centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http:///centos/RPM-GPG-KEY-CentOS-7

NetEase (163)

[163]
name=163 mirrors
baseurl=http://mirrors./centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors./centos/RPM-GPG-KEY-CentOS-7

Tsinghua University (TUNA)

[tuna]
name=TUNA mirrors
baseurl=http:///centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http:///centos/RPM-GPG-KEY-CentOS-7

The way to use these sources is usually to modify the/etc// directory of the.repo file, or create a new.repo file, add the above to the file.

The specific steps are as follows:

Backup the original YUM configuration file:

sudo cp /etc// /etc//

Modify the configuration file and replace it with one of the above. For example, use the AliCloud source:

sudo nano /etc//

Paste in the AliCloud configuration, save and exit the editor.

Clears the cache and generates a new one:

sudo yum clean all
sudo yum makecache