无论改啥文件,第一件事就是先把原来的备份!!!
无论改啥文件,第一件事就是先把原来的备份!!!
无论改啥文件,第一件事就是先把原来的备份!!!
- Ubuntu系统
- Centos7系统
Ubuntu系统
参考自:https://blog.csdn.net/zhangjiahao14/article/details/80554616
- 备份
mv /etc/apt/sources.list /etc/apt/sources.list.bak
- 查看系统的代号
lsb_release -c
Ubuntu 12.04 (LTS)代号为precise。
Ubuntu 14.04 (LTS)代号为trusty。
Ubuntu 16.04 (LTS)代号为xenial。
Ubuntu 18.04 (LTS)代号为bionic。
- 添加新的源文件
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
教育网请选择清华源,选择相应的版本,将内容复制到文件中。
- 更新
sudo apt update
Centos 7系统
参考自:https://www.cnblogs.com/renpingsheng/p/7845096.html
- 备份原有的源
mv CentOS-Base.repo CentOS-Base.repo.bak
- 下载国内的阿里云或网易的源文件
此处选择只下载阿里云的。
wget http://mirrors.aliyun.com/repo/Centos-7.repo
# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
教育网可使用清华源。
- 清除系统yum缓存
yum clean all
- 生成新的yum缓存
yum makecache
- 安装新的epel源
yum install -y epel-release
- 使用阿里镜像的epel源
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
- 重复上述清楚并生成缓存的操作
网友评论