Ubuntu22.04更换国内镜像源(阿里云)

本文指导如何在Ubuntu22.04系统中更改镜像源为阿里云源。首先备份source.list文件,然后清除文件内容并粘贴阿里云的镜像源URL,包括main,restricted,universe,multiverse及security和updates仓库。修改后运行sudoaptupdate使变更生效。

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

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

首先将source.list复制为source.list.bak备份。

cp /etc/apt/source.list /etc/apt/source.list.bak

修改完成后保存source.list文件,需要执行命令后才能生效:

sudo apt update

本文为 Ubuntu 22.04 的阿里云镜像源列表。若为其他版本,将所有jammy更改为其他版本代号即可。
常用的Ubuntu版本代号如下:
Ubuntu 22.04:jammy
Ubuntu 20.04:focal
Ubuntu 18.04:bionic
Ubuntu 16.04:xenia

vim /etc/apt/source.list

将文件内容清空,然后复制下方代码粘贴,wq保存退出即可。

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
Ubuntu 22.04 设置国内镜像源主要是为了加快软件包的下载速度,特别是对于非英语地区的用户。以下是设置阿里云和清华大学源的步骤: 1. **安装`software-properties-common`**: ```bash sudo apt-get update && sudo apt-get install software-properties-common ``` 2. **添加阿里云社区源** (替换`mirrors.aliyun.com`为其他版本如`mirrors.aliyuncs.com`): ```bash sudo add-apt-repository ppa:chenyunkun/aliyun-ubuntu-repo ``` 然后运行: ```bash sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E56151AF sudo apt update ``` 3. **选择阿里云仓库作为首选源**: ```bash sudo sed -i 's/#deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse/deb http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse/g' /etc/apt/sources.list sudo sed -i 's/#deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse/deb-src http://mirrors.aliyun.com/ubuntu focal main restricted universe multiverse/g' /etc/apt/sources.list ``` 4. **添加清华大学源** (替换`mirror.tuna.tsinghua.edu.cn`为其他版本): ```bash sudo add-apt-repository "deb [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse" sudo add-apt-repository "deb-src [arch=amd64] http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse" ``` 更新源列表: ```bash sudo apt update ``` 完成以上步骤后,Ubuntu 22.04 就会优先从国内镜像源下载软件包了。
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值