Ubuntu

Kevin2li大约 2 分钟

Ubuntu

阿里云镜像:https://developer.aliyun.com/mirror/ubuntuopen in new window
清华源镜像:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/open in new window

方法:

  • 修改配置文件
    配置文件路径:/etc/apt/sources.list
# 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 替换内容
sudo tee /etc/apt/sources.list << EOF

Ubuntu22.04示例:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

Debian

清华源:https://mirror.tuna.tsinghua.edu.cn/help/debian/open in new window

Debian11示例:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

deb https://security.debian.org/debian-security bullseye-security main contrib non-free
# deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free

pip

阿里云:https://developer.aliyun.com/mirror/pypi?spm=a2c6h.13651102.0.0.59f71b112m674Eopen in new window
清华源: https://mirror.tuna.tsinghua.edu.cn/help/pypi/open in new window

  • 终端临时使用
# 阿里云
pip install <package> -i https://mirrors.aliyun.com/pypi/simple/

# 清华源
pip install <package> -i https://pypi.tuna.tsinghua.edu.cn/simple
  • 写入配置文件

配置文件路径:~/.pip/pip.conf

内容:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

conda

清华源:https://mirror.tuna.tsinghua.edu.cn/help/anaconda/open in new window

  • 写入配置文件
    配置文件路径:~/.condarc
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

docker镜像加速站

阿里云:https://help.aliyun.com/document_detail/60750.htmlopen in new window

  • 写入配置文件

配置文件路径:/etc/docker/daemon.json (没有则新建)

添加下面条目:

{
    "registry-mirrors": ["<镜像加速器地址>"]
}    

登录容器镜像服务控制台open in new window,在左侧导航栏选择镜像工具 > 镜像加速器,在镜像加速器页面获取镜像加速地址。

image.png
image.png

重启服务:

sudo systemctl daemon-reload
sudo systemctl restart docker

验证:

docker info
image.png
image.png

能找到刚才自己设的Registry Mirrors,说明设置成功。

npm

参考: https://npmmirror.com/open in new window

 npm install -g <package> --registry=https://registry.npmmirror.com