配置Ubuntu镜像源

170 阅读1分钟

常见的国内镜像源

国内主要的Ubuntu镜像源包括:

本指南以中科大镜像为例

Ubuntu24.04之前版本 -- 操作步骤

1.查看Ubuntu版本代号

lsb_release -a

1.png
如图所示
我的Ubuntu版本代号是jammy

2.对源文件进行备份

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

3.使用中科大镜像源进行替换

sudo nano /etc/apt/sources.list

清空文件内容,写入下面内容(我的版本代号是jammy,不同版本代号只需要替换jammy位置即可):

deb http://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

4.更新软件列表

sudo apt update

2.png 如图所示
说明配置镜像源成功

Ubuntu24.04及之后版本 -- 操作步骤

Ubuntu 24.04 启用了新的 DEB822 格式,配置文件位置和写法都与旧版本不同

1.查看Ubuntu版本代号

lsb_release -a

3.png
如图所示
我的Ubuntu版本代号是noble

2.对源文件进行备份

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

3.使用中科大镜像源进行替换

sudo nano /etc/apt/sources.list.d/ubuntu.sources

清空文件内容,写入下面内容(我的版本代号是noble,不同版本进行对应替换即可):

Types: deb
URIs: http://mirrors.ustc.edu.cn/ubuntu/
Suites: noble noble-updates noble-backports noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

4.更新软件列表

sudo apt update

4.png 如图所示
说明配置镜像源成功