Ubuntu18.04下更改apt源为阿里云源

本文介绍了如何在Ubuntu18.04系统中更改apt源为阿里云源,包括备份源文件、编辑sources.list、添加阿里云源的详细步骤,以及更新软件列表和软件包的操作。通过此方法可以提高下载速度。

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

前言:看见Ubuntu新出了18.04版本感觉不错,装一个玩玩,虽然有很多教程可以参考,但我也给出一个不是很一样的方案吧,尽量解释的详细一点。

为了下载更方便,速度更快,我们往往在使用Linux系列系统时修改apt源为国内的源,一般选择有阿里云,豆瓣之类的,下面简单说下如何更改为阿里云源。

 

1.复制源文件备份,以防万一

我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。

命令如下:

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

 

2.编辑源列表文件

命令如下:

sudo vim /etc/apt/sources.list

如果报错:sudo:vim:command not found    说明没装vim编辑器

使用命令:

sudo apt-get install vim 安装即可

 

3.查看新版本信息

其实Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:

使用如下命令:

lsb_release -c

得到本系统的系统代号,如下图所示:

我们可以看到新版本的Ubuntu系统

<think>根据用户历史对话和当前需求,用户需要Ubuntu18.04国内APT列表及配置教程。此前用户遇到GPG签名错误,可能由于配置问题或密钥缺失。结合引用内容,国内常用包括阿里云、清华、中科大等。关键点:1.用户明确要求Ubuntu18.04(代号bionic)的2.需要解决GPG验证问题3.配置步骤应包含备份、修改文件、更新参考引用:-引用[1][3][4]提到阿里云配置,引用[2]提到阿里云、清华、中科大的配置模板-所有配置都需替/etc/apt/sources.list文件解决方案:1.提供主流国内源地址(阿里云、清华、中科大)2.给出具体配置步骤,强调版本号bionic3.补充GPG密钥修复方法(因历史错误可能与此相关)4.结构化呈现,方便用户直接操作注意事项:-必须强调地址中"bionic"不可更改-说明main/restricted等组件的含义-提醒用户根据网络环境选择最佳</think> 以下是适用于 **Ubuntu 18.04(代号 Bionic Beaver)** 的国内主流 APT 配置教程,重点解决更新时的 GPG 签名错误问题: --- ### 一、国内推荐 APT 列表 | 服务商 | 配置方案 | 访问延迟 | |----------|------------------------------------------------------------------------------------------------------|----------| | **阿里云** | `deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse`<br>`deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse`<br>`deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse`<br>`deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse` [^1][^3] | ★★★★ | | **清华大学** | `deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse`<br>`deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse`<br>`deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse`<br>`deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse` [^2] | ★★★★★ | | **中科大** | `deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse`<br>`deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse`<br>`deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse`<br>`deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse` [^2] | ★★★★☆ | > 注:公式中组件说明 > 设 $C = \{ \text{main}, \text{restricted}, \text{universe}, \text{multiverse} \}$ > 则完整配置为 $\displaystyle \bigcup_{c \in C} \text{deb [...] bionic-*} \, c$ --- ### 二、配置教程(解决GPG签名错误) #### 步骤 1:备份原配置 ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` #### 步骤 2:写入新(以阿里云为例) ```bash sudo tee /etc/apt/sources.list << 'EOF' deb http://mirrors.aliyun.com/ubuntu/ bionic 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-security main restricted universe multiverse EOF ``` #### 步骤 3:修复GPG密钥 ```bash # 导入Ubuntu官方密钥 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3B4FE6ACC0B21F32 # 更新本地缓存(强制忽略验证) sudo apt update -o Acquire::AllowInsecureRepositories=true --allow-unauthenticated sudo apt install ubuntu-keyring -y ``` #### 步骤 4:完整更新 ```bash sudo apt update && sudo apt upgrade -y ``` --- ### 三、组件说明[^4] | 组件 | 内容描述 | |-------------|------------------------------| | **main** | Canonical官方维护的开软件 | | **restricted** | 设备专用驱动(闭) | | **universe** | 社区维护的开软件 | | **multiverse** | 受版权限制的软件 | --- ### 四、验证配置 ```bash apt policy | grep -A5 "http" # 检查状态 curl -I http://mirrors.aliyun.com/ubuntu # 测试连接速度(200 OK即正常) ``` ---
评论 38
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值