<
>

Ubuntu更换国内镜像源(以阿里云为例)

创建时间:2024年9月16日 / 最近修改:2024年9月16日

Ubuntu采用apt作为软件安装工具,其镜像源列表记录在/etc/apt/source.list文件中。

 

因此我们先要切换到该目录下

 

cd /etc/apt/

 

然后我们要对原先的source.list文件进行备份!(这很重要,备份是一个非常好的习惯)

 

sudo cp source.list source.list.old

 

接着我们就要进行换源操作,

 

本次教程为 Ubuntu 22.04 的阿里云镜像源。如果你使用的是其他版本,将所有jammy更改为其他版本代号即可。
以下是常用的Ubuntu版本代号:
Ubuntu 22.04:jammy
Ubuntu 20.04:focal
Ubuntu 18.04:bionic
Ubuntu 16.04:xenia

 

我们先进入source.list的编辑中

 

sudo vi source.list

 

然后把里面的内容全部删掉,将以下内容复制进去(如果是其他版本,请将jammy替换掉)

 

deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

 

注:在vi中,先输入i则可进入编辑模式,编辑完成后按esc退出编辑模式,输入以下命令来保存退出,注意wq前有一个冒号:!!!

 

:wq

 

保存成功退出后,我们需要更新以下我们的源,来让系统知道下现在的源中有什么软件

 

sudo apt-get update

 

到此换源工作就全部结束啦

 

Nore_07

欢迎大家来到我的博客!

浏览量:517

点赞数:483

文章目录

开发中...

喜欢文章可以点赞支持哦