Ubuntu 18.04 配置国内源

本文介绍了如何在Ubuntu系统中更改软件源以提高下载速度。包括备份原配置文件、使用阿里云和中科大镜像源的方法及步骤,并指导用户完成系统软件包的更新。

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

打开配置文件

>sudo vi /etc/apt/sources.list
#deb cdrom:[Ubuntu 18.04.4 LTS _Bionic Beaver_ - Release amd64 (20200203.1)]/ 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

备份配置文件,.bak文件为备份文件


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

添加阿里源

直接修改/etc/apt/sources.list文件即可

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

中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

更新源


> sudo apt update 
> sudo apt upgrade

<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、付费专栏及课程。

余额充值