Linux更改镜像源(阿里云)


Linux更改镜像源(阿里云)

一、Ubuntu

1.将sources.list中的源文件备份到sources.list.bak中

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.命令行打开sources.list文件

sudo vim /etc/apt/sources.list

3.修改sources.list文件,将内容更换为阿里云源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

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

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

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

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

保存并退出.

4.更新源

sudo apt-get update

5.更新软件(这一步建议不操作,会更新很久)

sudo apt-get upgrade 

二、CentOS

1、安装wget

 yum install -y wget

2、下载CentOS 7的repo文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3、更新源

清除缓存

yum clean all

生成缓存

yum makecache

更新

yum -y update
教程