Linux软件数据源配置汇总

数据源

以下为国内主流的镜像源,大部分软件都可以在以下网站获取可替代的软件。

清华:https://mirrors.tuna.tsinghua.edu.cn 🔗

中科大:https://mirrors.ustc.edu.cn/help 🔗

网易:https://mirrors.163.com 🔗

阿里云:http://mirrors.aliyun.com 🔗

华为云:https://mirrors.huaweicloud.com/home 🔗

Ubuntu 配置apt-get数据源

更换方法

  • 旧版:在/etc/apt/sources.list文件中包含了当前使用的软件源列表文件内容,其中列出了用于获取软件包的各个软件仓库

  • 新版:在/etc/apt/sources.list.d/文件夹存放额外软件源配置文件的目录,用于用户自定义和管理额外的软件源,配置以.list结为拓展名即可,例如/etc/apt/sources.list.d/stretch-backports.list

常用的Ubuntu版本代号如下:

  • Ubuntu 22.04:jammy
  • Ubuntu 20.04:focal
  • Ubuntu 18.04:bionic
  • Ubuntu 16.04:xenial

配置数据源需要与版本对应,例如在Ubuntu 20.04中配置清华数据源

# 配置数据源
echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse" | tee /etc/apt/sources.list.d/stretch-backports.list

# 更新数据源
sudo apt update

# 安装时指定数据源
apt-get -t stretch-backports install foo

数据源

阿里云

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

清华

deb 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 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 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 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 http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse

参考:

Alpine Linux配置apk数据源

更换方法

在Alpine Linux中的apk数据源配置在/etc/apk/repositories ,以3.14版本为例。

https://dl-cdn.alpinelinux.org/alpine/v3.14/main
https://dl-cdn.alpinelinux.org/alpine/v3.14/community

配置只需将域名替换即可,以清华为例:

# 配置数据源
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

# 更新最新本地镜像源
apk update

# 升级软件
apk upgrade 

数据源

阿里云

sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

清华

sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

中科大

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

Centos配置yum数据源

更换方法

在Centos,yum的配置文件为/etc/yum.repos.d目录下, 其中有多个配置文件,每一个配置文件中都可以配置一个或多个repository

华为云

# 配置数据源
cat > /etc/yum.repos.d/CentOS-Base.repo << 'EOF'
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/updates/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - repo.huaweicloud.com
baseurl=https://repo.huaweicloud.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=https://repo.huaweicloud.com/centos/RPM-GPG-KEY-CentOS-7
EOF

# 清除系统所有的yum缓存
yum clean all 

# 生成新的yum缓存
yum makeacache 

# 查看所有yum源
yum repolist

数据源

清华https://mirrors.tuna.tsinghua.edu.cn/help/centos/ 🔗

网易http://mirrors.163.com/.help/centos.html 🔗

阿里云http://mirrors.aliyun.com/repo/Centos-7.repo 🔗

中科大https://mirrors.ustc.edu.cn/help/centos.html 🔗

lomtom

标题:Linux软件数据源配置汇总

作者:lomtom

链接:https://lomtom.cn/document/dnx67z29wcvo7