云计算、AI、云原生、大数据等一站式技术学习平台

网站首页 > 教程文章 正文

Ubuntu中apt设置国内源(以阿里云为例)

jxf315 2025-02-19 12:25:55 教程文章 14 ℃

在 Ubuntu 系统中,将 APT 源设置为阿里云源可以提高软件包更新和下载速度。

设置国内源

1. 备份现有的源列表:

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

2. 编辑 sources.list 文件:

使用以下命令打开 sources.list 文件:

sudo vi /etc/apt/sources.list

3. 替换内容为阿里源:

根据Ubuntu 版本,将内容替换为对应的阿里源。以下是常见版本的源地址:

Ubuntu 22.04 (Jammy):

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

Ubuntu 20.04 (Focal):

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

Ubuntu 18.04 (Bionic):

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

编辑完成后,保存并退出:

4. 更新软件包索引:

使用以下命令更新软件包索引:

sudo apt update

查找各种版本的包

可以在
https://launchpad.net/ubuntu/ 上查找对应版本的代码和二进制

添加图片注释,不超过 140 字(可选)

最近发表
标签列表