After you install some common softwares or programmers, usually the first thing you need to do is to change the source addresses of softwares or package managers for chinese users. Here are some common tutorials.
Change Apt-get Repository Source
ubuntu20.04 LTS
We take the ubuntu20.04 LTS as an example.
1 2 3 4 5 6 7 8 9
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak # backup (optional) sudo vi /etc/apt/sources.list # edit the source list file
# file: /etc/apt/sources.list # comment out the original content and add the content below (Tsinghua University source) deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
sudo apt-get update # update list
Attention:
“deb” source address corresponds to the command apt, which will only get the binary files without compiling, and “deb-src” source address corresponds to the command apt-get, which may get the source codes and compile them.
the format of source address is
1 2
deb http://site.example.com/debian distribution component1 component2 component3 deb-src http://site.example.com/debian distribution component1 component2 component3
where the “distribution” is usually “ubuntuCodeName-sourceBranch”.
ubuntuCodeName is related to the version of ubuntu system and can be found by the command lsb_release -a. Here are some ubuntu alias name:
sourceBranch is usually *”empty”*/security/updates/backports/proposed. Proposed branch is pre-release software source, which is not recommended to use.
component is usually main/restricted/universe/multiverse
If your system is not ubuntu20.04 LTS, you need to replace the source address by yourself.
Here are some famous repository source addresses (ubuntu20.04 LTS):
# Tsinghua University deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# University of Science and Technologyof China deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# Ali Cloud deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
Respberry Pi
The first thing you need to do is finding the code name of your respbian system version by command lsb_release -a
Take an example whose code name is “bullseye”(Respberry Pi 4b):
Comment the original content and additional content you need to add in /etc/apt/sources.list file:
1 2
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ bullseye main non-free contrib rpi
And in /etc/apt/sources.list.d/raspi.list file, you need to comment the original content as well and add:
1
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main ui
If your system has another code name, just replace the code name part of the address and do the same thing.
Don’t forget to execute sudo apt-get update
Change Pip Repository Source
Assuming you have successfully install Python3 and Pip package manager, do the following steps.
Temporary Use:
1
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple # use -i parameter
Permanent Use:
1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Here are some famous pip source addresses:
Address
1 2 3 4
https://pypi.tuna.tsinghua.edu.cn/simple/ # Tsinghua University https://pypi.mirrors.ustc.edu.cn/simple/ # University of Science and Technologyof China http://mirrors.aliyun.com/pypi/simple/ # Ali Cloud http://mirrors.myhuaweicloud.com/pypi/web/simple # Huwwei Cloud
Change Docker Reposition Address
1 2 3 4 5 6 7 8
sudo vi /etc/docker/daemon.json
# add the following content in daemon.json file { "registry-mirrors": ["https://registry.docker-cn.com"] }
sudo service docker restart # restart docker
Here are some famous docker mirror reposition addresses:
Address
1 2
https://registry.docker-cn.com # Docker china official address https://kfwkfulq.mirror.aliyuncs.com # Ali Cloud
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" brew tap --custom-remote --force-auto-update homebrew/core https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git brew tap --custom-remote --force-auto-update homebrew/cask-fonts https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git brew tap --custom-remote --force-auto-update homebrew/cask-drivers https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-versions.git brew tap --custom-remote --force-auto-update homebrew/command-not-found https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-command-not-found.git
brew update
Or use script here,
1 2 3 4 5 6 7 8
#!/bin/bash export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git" brew update export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git" for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do brew tap --custom-remote --force-auto-update "homebrew/${tap}""https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-${tap}.git" done brew update
Adding environment paths to ~/.zprofile is recommended.
unset HOMEBREW_CORE_GIT_REMOTE BREW_TAPS="$(BREW_TAPS="$(brew tap 2>/dev/null)"; echo -n "${BREW_TAPS//$'\n'/:}")" for tap in core cask{,-fonts,-drivers,-versions} command-not-found; do if [[ ":${BREW_TAPS}:" == *":homebrew/${tap}:"* ]]; then # 只复原已安装的 Tap brew tap --custom-remote "homebrew/${tap}" "https://github.com/Homebrew/homebrew-${tap}" fi done brew update