Change the domestic yum or apt source for each distribution of the Linux system to speed up software download and update

Introduction: Centos, Ubuntu, Debian, Fedora, OpenSUSE, FreeBSD system change software source

Centos, Ubuntu, Debian, Fedora, OpenSUSE, FreeBSD system change software source
After the Linux system is installed, the software sources are generally foreign servers, which are particularly slow in China. At this time, it is necessary to replace the domestic mirror source.
Cost-effective and cheap VPS/cloud server recommendation: https://blog.zeruns.tech/archives/383.html
【Linux system replaces domestic mirror source】Centos
1. Backup
mv /etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup _ _ _ _ _ _ _ _ _ _
2. Replace the source
Download the new CentOS - Base.repo to /etc/yum.repos.d/ _
wget -O /etc/yum.repos.d /CentOS-Base.repo http://mirrors.aliyun.com/repo /Centos-7.repo _ _ _ _ _ _
or
curl -o / etc / yum .repos.d /CentOS-Base.repo http://mirrors.aliyun.com/repo /Centos-7.repo _
Note that the 7 in http://mirrors.aliyun.com/repo/Centos-7.repo is changed to your own Centos version number, for example, Centos 8 is http://mirrors.aliyun.com/repo/Centos-8.repo .
3. Run yum makecache to generate the cache
yum makecache
【Linux system replaces domestic mirror source】Ubuntu
1. Backup
sudo cp /etc/apt/sources.list /etc/apt/sources_init.list _ _ _ _ _ _ _ _
Make a backup of the previous source in case it can be used later.
2. Change the file permissions to make it editable
sudo chmod 777 /etc/apt/source.list _ _ _ _
3. Replace the source
sudo nano / etc /apt/sources.list _
Use nano to open the text, delete the contents of the original file, copy one of the sources below, and save.
Aliyuan:
deb http: //mi rrors.aliyun.com /ubuntu/ xenial main restricted universe multiverse
deb http: //mi rrors.aliyun.com /ubuntu/ xenial -security main restricted universe multiverse
deb http: //mi rrors.aliyun.com /ubuntu/ xenial -updates main restricted universe multiverse
deb http: //mi rrors.aliyun.com /ubuntu/ xenial -proposed main restricted universe multiverse
deb http: //mi rrors.aliyun.com /ubuntu/ xenial -backports main restricted universe multiverse
deb- src http: //mi rrors.aliyun.com /ubuntu/ xenial main restricted universe multiverse
deb- src http: //mi rrors.aliyun.com /ubuntu/ xenial -security main restricted universe multiverse
deb- src http: //mi rrors.aliyun.com /ubuntu/ xenial -updates main restricted universe multiverse
deb- src http: //mi rrors.aliyun.com /ubuntu/ xenial -proposed main restricted universe multiverse
deb- src http: //mi rrors.aliyun.com /ubuntu/ xenial -backports main restricted universe multiverse
Tsinghua source:
deb http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic main restricted universe multiverse
deb - src http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic main restricted universe multiverse
deb http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-updates main restricted universe multiverse
deb - src http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-updates main restricted universe multiverse
deb https : //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-backports main restricted universe multiverse
deb - src http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-backports main restricted universe multiverse
deb http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-security main restricted universe multiverse
deb - src http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-security main restricted universe multiverse
deb http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-proposed main restricted universe multiverse
deb - src http s: //mirrors.tuna.tsinghua.edu.cn / ubuntu / bionic-proposed main restricted universe multiverse
3. Update
update source
sudo apt- get update
Fix broken packages, try uninstalling the wrong package, and reinstall the correct version.
sudo apt-get -f install
update software
sudo apt-get upgrade
Debian
1. Backup
sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak _ _ _ _ _ _ _ _
2. Replace the source
In general, replace the Debian default source address http://deb.debian.org in the /etc/apt/sources.list file with http://mirrors.ustc.edu.cn ( Tsinghua source ) .
sudo sed -i ' s /deb.debian.org/mirrors.ustc.edu.cn/g ' /etc/apt/sources.list _
You can also edit the /etc/apt/sources.list file directly ( v )
sudo vi /etc/apt/sources.list _ _ _ _
Just add the following
deb http://mirrors.ustc.edu.cn / debian stable main contrib non-free
# deb - src http://mirrors.ustc.edu.cn / debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn / debian stable-updates main contrib non-free
# deb - src http://mirrors.ustc.edu.cn / debian stable-updates main contrib non-free

# deb http://mirrors.ustc.edu.cn / debian stable-proposed-updates main contrib non-free
# deb - src http://mirrors.ustc.edu.cn / debian stable-proposed-updates main contrib non-free
Hit the i key to enter the insert mode, the key combination ctrl+shift+v will paste the copied content into the source file, hit the esc key to enter the command mode, enter : wq ! Save and exit.
Other mirror sources:
Alibaba Cloud: http://mirrors.aliyun.com/Sohu
: http://mirrors.sohu.com/
NetEase: http://mirrors.163.com/
3. Update
sudo apt- get update
Fedora
su
cd /etc/yum.repos.d/ _ _ _ _ _ _
mv fedora.repo _ fedora.repo.backup _
mv fedora- updates .repo fedora- updates .repo.backup
wget -O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo _ _ _ _ _ _ _ _
wget -O / etc / yum .repos .d /fedora-updates.repo http : //mirrors.aliyun.com/repo/fedora-updates.repo
dnf clean all
dnf makecache
OpenSUSE
1. Disable the original software source
sudo zypper mr -da
2. Add HKUST mirror source
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/oss USTC:42.1: OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.1/repo/non-oss USTC: 42.1 :NON -OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/oss USTC: 42.1 :UPDATE - OSS
sudo zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.1/non-oss USTC : 42. 1 : UPDATE -NON -OSS
3. Manually refresh the software source
sudo zypper ref
4. Update the system
sudo zypper up
FreeBSD
1. Modify the pkg source
mkdir -p / usr /local/ etc /pkg/repos
vim /usr/local/etc/pkg/repos/FreeBSD.conf _ _ _ _

# content of FreeBSD.conf
FreeBSD: {
url : " pkg+ http://mirrors.ustc.edu.cn/ freebsd -pkg /${ ABI}/quarterly",
}
2. Modify the ports source
vim /etc/make.conf _ _ _ _ _

# content of make.conf _ _
FETCH_CMD=axel -n 10 - a
DISABLE_SIZE=yes
MASTER_SITE_ OVERRIDE ? = http://mirrors.ustc.edu.cn/freebsd-ports/distfiles/${DIST_SUBDIR}/
3. Modify portsnap source
vim /etc/portsnap.conf _ _ _

# content of porsnap.conf
SERVERNAME = porsnap.tw.freebsd.org
recommended article:
Build an intranet penetration server with a web panel: https://blog.zeruns.tech/archives/397.html
How to build a personal blog: https://blog.zeruns.tech/archives/218.html
CentOS 7 install new kernel and enable Google BBR tutorial: https://blog.zeruns.tech/archives/39.html
vultr $2.5 pure ipv6 server + CDN to build a website that supports both ipv4 and ipv6: https://blog.zeruns.tech/archives/345.html
up AdGuard Home ad-free and tracking DNS server: https://blog.zeruns.tech/archives/318.html
Copyright statement: The content of this article is contributed by Alibaba Cloud's real-name registered users. The copyright belongs to the original author. The Alibaba Cloud developer community does not own the copyright and does not assume the corresponding legal responsibility. For specific rules, please refer to the " Alibaba Cloud Developer Community User Service Agreement " and " Alibaba Cloud Developer Community Intellectual Property Protection Guidelines ". If you find any content suspected of plagiarism in this community, fill out the infringement complaint form to report it. Once verified, this community will delete the allegedly infringing content immediately.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00