【Linux】更换Linux系统的安装源

无论改啥文件,第一件事就是先把原来的备份!!!
无论改啥文件,第一件事就是先把原来的备份!!!
无论改啥文件,第一件事就是先把原来的备份!!!
另外,更换系统源需要root权限。

  • Ubuntu系统
  • Centos7系统

Ubuntu系统

参考自:https://blog.csdn.net/zhangjiahao14/article/details/80554616

  1. 备份
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 查看系统的代号
sudo lsb_release -c

Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 16.04 (LTS)代号为xenial。
Ubuntu 18.04 (LTS)代号为bionic。

  1. 添加新的源文件
sudo vi /etc/apt/sources.list

下面是Ubuntu16.04 阿里云源,将以下内容复制到文件中。

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

教育网请选择清华源,选择相应的版本,将内容复制到文件中。

  1. 更新
sudo apt update

Centos 7系统

参考自:https://www.cnblogs.com/renpingsheng/p/7845096.html

  1. 备份原有的源
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
  1. 下载国内的阿里云或网易的源文件
    此处选择只下载阿里云的。
sudo wget http://mirrors.aliyun.com/repo/Centos-7.repo
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

教育网可使用清华源。

  1. 清除系统yum缓存
sudo yum clean all
  1. 生成新的yum缓存
sudo yum makecache
  1. 安装新的epel源
sudo yum install -y epel-release
  1. 使用阿里镜像的epel源
sudo wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
  1. 重复上述清楚并生成缓存的操作

你可能感兴趣的:(【Linux】更换Linux系统的安装源)