跳到主要内容

Ubuntu 系统使用阿里源

小林
后端开发工程师, 专注Go开发、微服务和云原生

Ubuntu 系统使用阿里源, 包含 Ubuntu 24.04 版本, 包含 debian 系统, 持续更新

备份原 sources.list 文件

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

Ubuntu 使用阿里源

sed -i "s@http://.*archive.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list && \
sed -i "s@http://.*security.ubuntu.com@http://mirrors.aliyun.com@g" /etc/apt/sources.list

Ubuntu 24.04(noble)

Ubuntu 24.04 使用新的Sources格式配置文件, 主要配置位于 /etc/apt/sources.list.d/ubuntu.sources, 而非传统的 sources.list 文件

备份原 sources.list 文件

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

修改配置为阿里源

sed -i 's@archive.ubuntu.com@mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources && \
sed -i 's@security.ubuntu.com@mirrors.aliyun.com@g' /etc/apt/sources.list.d/ubuntu.sources

Debian 使用阿里源

sed -i "s@deb.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list

Debian 12(bookworm)

sed -i "s@deb.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list.d/debian.sources

更新系统

apt update && apt upgrade -y