记录常见linux操作系统的源以及换源方式。

Linux发行版分类

Linux的发行版本根据维护主体的不同可以大体分为两类,一类是商业公司维护的发行版本,一类是社区组织维护的发行版本,前者以著名的Red Hat(RHEL红帽)为代表,后者以Debian为代表。

更多介绍见 https://www.edrawsoft.cn/linux-classify-function/

https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

RedHat系列(基于RPM)

Redhat系列的包管理方式采用的是基于RPM包和YUM包的管理方式,包分发方式是编译好的二进制文件。

  • RHEL (Redhat Enterprise Linux):也就是所谓的Redhat Advance Server,收费版本,稳定性非常好,适合服务器使用。
  • Fedora Core :由原来的Redhat桌面版本发展而来,免费版本,稳定性较差,最好只用于桌面应用, 用户可免费体验到最新的技术或工具,而功能成熟后会被加入到RHEL系统中。因此也被称为RHEL系统的“试验田”。
  • CentOS:RHEL的社区克隆版本,免费版本,稳定性非常好,适合服务器使用,CentOS 是RHEL源代码再编译的产物,而且在RHEL的基础上修正了不少已知的 Bug ,相对于其他 Linux 发行版,其稳定性值得信赖。
  • OpenSUSE: 德国著名的Linux系统,全球范围内有着不错的声誉及市场占有率,发行量在欧洲占第一位。。OpenSUSE对个人来说是完全免费的,包括使用和在线更新。

Debian系列

包括Debian和Ubuntu等。Debian是社区类Linux的典范,是迄今为止最遵循GNU规范的Linux系统。提供了接近十万种不同的开源软件支持,在国外用于很高的认可度和使用率。对于各类内核架构支持性良好,稳定性、安全性强更有免费的技术支持。

Debian最具特色的是apt-get / dpkg包管理方式。
分为三个版本分支(branch):

  • unstable,为最新的测试版本,其中包括最新的软件包,但是也有相对较多的bug,适合桌面用户。
  • testing,经过unstable中的测试,相对较为稳定,也支持了不少新技术。
  • stable,一般只用于服务器,上面的软件包大部分都比较过时,但是稳定和安全性都非常的高。

Debian系列

换源方式

cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份原来的源
vim /etc/apt/sources.list #使用vim编辑器输入新的源
apt-get update #更新

debian9源

debian9美国官方源

deb http://ftp.us.debian.org/debian/ stretch main non-free contrib
deb http://ftp.us.debian.org/debian/ stretch-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ stretch main non-free contrib
deb-src http://ftp.us.debian.org/debian/ stretch-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ stretch-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch-backports main contrib non-free
deb http://security.debian.org/ stretch/updates main
deb-src http://security.debian.org/ stretch/updates main

debian9 163镜像源

deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib

debian9 中科大镜像源

deb https://mirrors.ustc.edu.cn/debian/ stretch main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ stretch main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ stretch-updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ stretch-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ stretch-backports main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ stretch-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ stretch/updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian-security/ stretch/updates main contrib non-free

debian9 阿里云镜像源

deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib

debian9 清华镜像源

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free

debian10源

debian10美国官方源

deb http://ftp.us.debian.org/debian/ buster main non-free contrib
deb http://ftp.us.debian.org/debian/ buster-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ buster main non-free contrib
deb-src http://ftp.us.debian.org/debian/ buster-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ buster-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ buster-backports main contrib non-free
deb http://security.debian.org/ buster/updates main
deb-src http://security.debian.org/ buster/updates main

debian10阿里源

deb http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib
deb http://mirrors.aliyun.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian-security/ buster/updates main non-free contrib

debian10网易源

deb http://mirrors.163.com/debian/ buster main non-free contrib
deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ buster main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib

debian10中科大源

deb https://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free
 
deb-src https://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free
deb-src https://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free

ubuntu16.04源

官方源

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

ubuntu18.04源

待添加

RedHat系列

yum、epel、rpm

repo是配置源的,即配置从哪里下载包(以及依赖关系)的。

epel是作为桥的,centos等企业linux不具有repo,yum的功能,所以需要安装epel,使得其具有yum功能。

centos是redhat的开源版本,是企业linux系列的,没有yum功能, 所以需要配置epel。

配置了epel,又需要配置repo,以使得软件源有软件,且软件是较新的较全的。


RPM,全称为RPM Package Manager,是由Red Hat推出的软件包管理系统,现在在各种发行版中普遍使用。RPM仅适用于安装用RPM来打包的软件,目前是GNU/Linux下软件包资源最丰富的软件包类型。

Yum (Yellow dog Updater, Modified) 是一个基于 RPM 包管理的字符前端软件包管理器,能够从指定的服务器自动下载 RPM 包并且安装,可以自动解决处理包依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装,更方便的添加/删除/更新RPM包,便于管理系统的更新问题。被Yellow Dog Linux本身,以及Fedora、Red Hat Enterprise Linux采用。

Yum和RPM的关系就如同apt(前端)和dpkg(后端)。

换源方式

如果需要备份现有源,可以参考以下命令

mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/*.* /etc/yum.repos.d/backup

换源过程

使用wegt或curl命令下载repo文件到/etc/yum.repos.d/文件下

更新源命令

yum clean all
yum makecache
#查看源列表
yum repolist all

Cento7 换源

阿里云

阿里云的各种源 http://mirrors.aliyun.com/repo/

wget -O /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel-7-Aliyun.repo http://mirrors.aliyun.com/repo/epel-7.repo

网易源

wget -O /etc/yum.repos.d/CentOS7-163-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo