CentOS / Ubuntu / Debian common version replacement domestic source method

After the Linux system is installed, the software source is usually a foreign server, which is particularly slow in China. At this time, you need to replace the domestic mirror source. Such as 163, aliyun and mirror sources of various universities. Remember to back up the original source first before replacing the source, in case it will be used later.
1. CentOS
1. Backup: mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. Change 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 http://mirrors.aliyun.com/repo/Centos-7.repo 7 changed to its own Centos version number, for example, Centos 8 is http://mirrors.aliyun.com/repo/Centos-8.repo.
3. Run yum makecache generate cache
two. Ubuntu
1. Backup: sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
2. Change the file permissions to make it editable sudo chmod 777 / etc / apt / source .list
3. Change 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 following sources into it, and save it.
Aliyuan:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

Tsinghua source:

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://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 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

4. Update source: sudo apt-get update
5. Repair damaged software package: sudo apt-get -f install
6. Update software: sudo apt-get upgrade

3. Debian
1. Backup: sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
2. Replace the source: the default source address of Debian in the /etc/apt/sources.list file http: // Replace deb.debian.org with http://mirrors.ustc.edu.cn (Tsinghua Source). Command: sudo sed -i 's / deb.debian.org / mirrors.ustc.edu.cn / g' /etc/apt/sources.list
can also directly edit the /etc/apt/sources.list file (v)
command : Sudo vi /etc/apt/sources.list Add the following content

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 pastes the copied content into the source file, hit the esc key to enter the command mode, enter: wq!

Other mirror sources:
Alibaba Cloud: http://mirrors.aliyun.com/
Sohu: http://mirrors.sohu.com/
NetEase: http://mirrors.163.com/

3.更新 sudo apt-get update

Published 117 original articles · praised 48 · 300,000 views +

Guess you like

Origin blog.csdn.net/jamesdodo/article/details/105703824