Ubuntu 操作系统更换国内源

本文详细介绍了如何在Ubuntu系统中备份原有源列表,然后替换为阿里云镜像,包括添加阿里公钥,更新源并升级软件版本的操作步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu 更换国内源

操作步骤

1. 对先前内容进行备份

// 备份源内容 (需要管理员权限)
> sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

在这里插入图片描述

2. 更换国内源文

2.1 更换阿里源
// 阿里源
> echo  "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list

在这里插入图片描述

2.2 添加阿里公钥
// 添加公钥Key
> sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32

在这里插入图片描述

3. 更新源及软件版本

> sudo apt update -y 
> sudo apt upgrade -y

在这里插入图片描述