Ubuntu18.04 apt 换源

本文介绍了Ubuntu系统中遇到无法修正错误时如何换源,并提供了详细的换源步骤。首先,通过编辑/etc/apt/sources.list文件替换源,然后运行`sudo apt-get update`更新源。但要注意,换源可能会导致某些仓库没有Release文件,这时需谨慎操作,必要时可回滚到原始源。文章给出了适用于Ubuntu 18.04的官方源列表。

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

经常遇到 无法修正错误,因为您要求某些软件包保持现状(换源)

参考这篇文章换源修复

各种源的列表

设置apt源的文件位置 :

sudo vim etc/apt/sources.list
然后粘贴源的内容

换完之后

sudo apt-get update

换源需谨慎,可能遇到如下问题

E: 仓库 “http://mirrors.tuna.tsinghua.edu.cn/ubuntu quantal-proposed Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源

所以如果不行,就还是用原来的吧

ubuntu18.04 原始的源

# deb cdrom:[Ubuntu 18.04.3 LTS _Bionic Beaver_ - Release amd64 (20190805)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

<think>我们正在解决Ubuntu18.04系统中配置apt国内源的问题。根据引用内容,我们可以通过两种方式实现:命令行方式(编辑sources.list文件)和图形界面方式(推荐)。引用[1][2][3][4][5]都提到了备份源文件、替换为国内镜像源(如阿里云、清华、中科大等)、更新源列表的基本步骤。我们将提供两种方法:方法一:图形界面方式(推荐,操作简单)方法二:命令行方式(适合熟悉命令行的用户)注意:Ubuntu18.04的系统代号是bionic。以下是详细步骤:</think> 以下是为Ubuntu 18.04配置APT国内源的详细教程,提供命令行和图形界面两种方法: --- ### **方法一:图形界面配置(推荐)** 1. **打开软件源设置** ```bash sudo software-properties-gtk ``` ![软件源设置界面](https://i.imgur.com/example.png) 2. **选择国内镜像源** - 在"下载自"下拉菜单中选择: ``` Main server → 中国的服务器 → [阿里云/清华/中科大] ``` - 或直接点击"选择最佳服务器"自动测试 3. **点击"关闭"后自动更新** - 系统会自动验证并更新源列表 > 此方法无需手动编辑文件,操作简单不易出错[^4] --- ### **方法二:命令行配置** #### **步骤1:备份原始源文件** ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` #### **步骤2:编辑源文件** ```bash sudo nano /etc/apt/sources.list ``` 删除全部内容,替换为以下任一镜像源: #### **选项A:阿里云源** ```bash 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-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 main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse ``` [^3][^5] #### **选项B:清华源** ```bash deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse ``` [^1][^2] #### **步骤3:更新软件源** ```bash sudo apt update && sudo apt upgrade -y ``` --- ### **验证配置** ```bash apt policy | grep http # 应显示选择的镜像地址(如mirrors.aliyun.com) ``` --- ### **关键技术说明** - **Ubuntu版本代号**:18.04代号`bionic`,20.04为`focal`[^3] - **APT源结构**: ```math \text{deb} \quad \underbrace{\text{http://site.com/ubuntu}}_\text{镜像地址} \quad \overbrace{\text{bionic}}^\text{版本} \quad \underbrace{\text{main restricted}}_\text{组件} ``` - **更新原理**:`apt update`重新下载`Packages.gz`索引文件 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值