ubuntu 换源

安装的英文版Ubuntu Server 16.04.1 LTS默认软件源为英国的,下载速度慢。为提高下载速度,将源改为国内的cn.archive.ubuntu.com ,其指向阿里云开源镜像站。重命名原源备份,更新apt软件源后,下载速度大幅提升,8M宽带可达1000多k。

查看所用的源

$ sudo vim /etc/apt/sources.list

由于安装的Ubuntu Server 16.04.1 LTS是英文版的,软件源就默认都是 us.archive.ubuntu.com(英国) 的,所以很慢。


# deb cdrom:[Ubuntu-Server 16.04.1 LTS _Xenial Xerus_ - Release amd64 (20160719)]/ xenial main restricted

#deb cdrom:[Ubuntu-Server 16.04.1 LTS Xenial Xerus - Release amd64 (20160719)]/ xenial 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/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-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/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-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/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-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/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-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 xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

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

为了提高下载速度,将源改为国内的 cn.archive.ubuntu.com ,现在 cn.archive.ubuntu.com 指向阿里云的开源镜像站 mirrors.aliyun.com,下载速度很快。


1. 重命名原来的源作为备份:

$ sudo mv /etc/apt/sources.list sources.list_backup

2. 新建一个 sources.list文件

$ sudo vim /etc/apt/sources.list
输入如下内容并保存退出:

deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://cn.archive.ubuntu.com/ubuntu/ xenial universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://cn.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse


3. 更新apt软件源:

$ sudo apt-get update

结束,以后更新下载软件就快多了。



我现在升级全部软件,试试下载速度怎样。

$ sudo apt-get dist-upgrade
有几十个软件有更新。


可以看到,下载速度达到了1000多k(从us.archive.ubuntu.com下载只有十几k),我开的是8M宽带,已经是极限了。


全部更新完使用了6分这样

<think>我们正在讨论如何更换Ubuntu系统的软件源。根据引用[1]和引用[2],更换软件源的方法主要是编辑`/etc/apt/sources.list`文件,替换为国内镜像源(如清华源或阿里云源),然后执行更新命令。 用户的问题:我想更换Ubuntu系统的软件源,请问Ubuntu更换软件源方法? 步骤: 1. 备份原来的软件源列表文件(以防需要恢复): ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 2. 编辑`sources.list`文件,删除原有内容,替换为国内镜像源。这里提供两种常用源(以Ubuntu 16.04 xenial为例,如果用户是其他版本,需要替换版本代号): - 清华源(引用[1]): ``` deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse ``` - 阿里云源(引用[2]): ``` deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse ``` 3. 保存文件后,在终端执行更新命令: ```bash sudo apt update ``` 注意:不同Ubuntu版本代号不同,例如18.04是bionic,20.04是focal。用户需要根据自己系统版本选择对应的源。 如果用户不确定自己的Ubuntu版本,可以通过以下命令查看: ```bash lsb_release -a ``` 例如,如果输出中Codename为focal,则对应Ubuntu 20.04。 因此,完整的步骤应该是: 1. 确定Ubuntu版本代号。 2. 选择镜像源(清华、阿里云等),并获取对应版本的源地址。 3. 备份并替换`sources.list`文件。 4. 更新软件列表。 另外,也可以使用图形界面更换软件源:在“软件和更新”中选择“下载自”的服务器,但这种方法有时不如手动编辑可靠。 最后,建议用户选择一个国内源,这样下载软件包会更快。 相关问题: 1. 如何查看Ubuntu系统的版本和代号? 2. 更换软件源后出现错误如何解决? 3. 除了清华源和阿里云源,还有哪些常用的国内软件源?</think>### Ubuntu 更换软件源方法 更换Ubuntu软件源可大幅提升软件下载速度,以下是详细步骤(以清华源为例): 1. **备份原配置文件** ```bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 2. **确定系统版本代号** ```bash lsb_release -c # 查看Codename(如focal、jammy等) ``` 3. **编辑源列表文件** ```bash sudo nano /etc/apt/sources.list ``` 删除全部内容,根据系统版本替换为对应的源(示例为Ubuntu 20.04 focal): ``` deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse ``` [^1] 4. **更新软件列表** ```bash sudo apt update && sudo apt upgrade -y ``` **常用国内源替换方案**: | 镜像源 | 适用版本 | 特点 | |-----------|---------------|--------------------------| | 清华源 | 全版本 | 更新快,支持HTTPS | | 阿里云源 | 全版本 | 稳定性高,CDN加速 | | 中科大源 | 较新版本 | 教育网优化 | 阿里云源示例(Ubuntu 22.04 jammy): ``` deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse ``` [^2] **注意事项**: 1. 操作需root权限,建议在终端操作 2. 更换源后如出现依赖错误,可尝试 `sudo apt --fix-broken install` 3. 企业环境建议使用内网镜像源 4. 图形界面用户可通过"软件和更新"→"下载自"切换
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值