Collection for Package Sources
TyeYeah Lv4

This is for programers in China, where people are a bit inconvenient to go online (off the G^F^W).
After changing to the native source, obtaining updates gets faster.

Change Linux Repository Mirror Sources

Sources can be edited in /etc/apt/sources.list, and you have the following sources (take kali for example) as alternatives to write in this file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# USTC
deb http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib
deb-src http://mirrors.ustc.edu.cn/kali kali-rolling main non-free contrib

# Aliyun
#deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib
#deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib

# TUNA
#deb http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free
#deb-src https://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling main contrib non-free

# ZJU
#deb http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free
#deb-src http://mirrors.zju.edu.cn/kali kali-rolling main contrib non-free

# SJTU
#deb https://mirrors.sjtug.sjtu.edu.cn/kali kali-rolling main non-free contrib
#deb-src https://mirrors.sjtug.sjtu.edu.cn/kali kali-rolling main non-free contrib

# Neusoft
#deb http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib
#deb-src http://mirrors.neusoft.edu.cn/kali kali-rolling/main non-free contrib

# NWAFU
#deb https://mirrors.nwafu.edu.cn/kali kali-rolling main non-free contrib
#deb-src https://mirrors.nwafu.edu.cn/kali kali-rolling main non-free contrib

Recently we encounter “E: Some index files failed to download. They have been ignored, or old ones used instead.”.
Change source and delete everything under /var/lib/apt/lists/, then update.

Deal with problems about public key:

1
wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add

Change pip Sources

Temporary Way

1
$ pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple # use it for once

Long-term Way

1
2
3
4
$ vim  ~/.pip/pip.conf  # edit or create it

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

Or one command to configure

1
$ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Some other sources

1
2
3
4
5
aliyun: http://mirrors.aliyun.com/pypi/simple/ 
ustc: https://pypi.mirrors.ustc.edu.cn/simple/
douban: http://pypi.douban.com/simple/
hust: http://pypi.hustunique.com/
...

For windows this file is in C:\Users\-YourUserName-\pip\pip.ini

On some latest released Linux like Ubuntu 20.xx, the pip of Python2 (python2-pip) is not included in the official repo, so we install it by get-pip.py:

1
2
3
4
5
$ sudo apt update 
$ sudo apt install python2
$ curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
$ sudo python2 get-pip.py # no `sudo` if install only for u
$ pip2 --version # check

Change Docker Registry

Just edit the file

1
2
3
4
5
$ vim /etc/docker/daemon.json

{
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}

Some others

1
2
3
4
5
6
7
8
netease: http://hub-mirror.c.163.com
ustc: https://docker.mirrors.ustc.edu.cn
aliyun: https://pee6w651.mirror.aliyuncs.com
https://kfwkfulq.mirror.aliyuncs.com
https://2lqq34jg.mirror.aliyuncs.com
http://<personal ID>.mirror.aliyuncs.com
Visit `https://cr.console.aliyun.com/` to get your own aliyun accelerate ID
...

Then we do

1
2
$ systemctl  daemon-reload
$ systemctl restart docker

If you run docker on windows, I highly recommend you to use virtualbox to be the host, which is convenient to update, storage expansion and network configuration.

Change gem Sources

Update first(ruby developer does)

1
2
3
$ gem update --system  # oh this step needs to climb off the G F W
$ gem -v
2.6.3

Then change sources

1
2
3
4
$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
$ gem sources -l
https://gems.ruby-china.com
# make sure there is only 'gems.ruby-china.com'

If you are using Gemfile or Bundler
Edit Gemfile

1
2
3
source 'https://gems.ruby-china.com/'
gem 'rails', '4.2.5'
...

or just

1
$ bundle config mirror.https://rubygems.org https://gems.ruby-china.com

Change npm Registry

You can replace npm with cnpm, then use cnpm to install packages.

Install the cnpm by

1
$ npm install -g cnpm --registry=https://registry.npm.taobao.org

Or, change package source can be conducted by

1
$ npm config set registry https://registry.npm.taobao.org

Then see the result

1
$ npm config list

Change go Sources

Execute

1
2
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn

or change envs

1
2
$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn,direct
Powered by Hexo & Theme Keep
Total words 135.7k