如何更换Ubuntu软件源

76次阅读
没有评论

共计 4694 个字符,预计需要花费 12 分钟才能阅读完成。

本文丸趣 TV 小编为大家详细介绍“如何更换 Ubuntu 软件源”,内容详细,步骤清晰,细节处理妥当,希望这篇“如何更换 Ubuntu 软件源”文章能帮助大家解决疑惑,下面跟着丸趣 TV 小编的思路慢慢深入,一起来学习新知识吧。

什么是 Ubuntu 的软件源?

我们在使用 Debian 或者 Ubuntu 的 apt-get 工具来安装需要的软件时,其实就是从服务器获取需要安装的软件并把它安装在本地计算机的过程。所谓的软件源,就是我们获取软件的来源,它是定义在 /etc/apt/sources.list 文件里的。

默认的 sources.list 文件内容如下:

## deb cdrom:[Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8)]/ xenial main restricted#deb cdrom:[Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8)]/ 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 universedeb 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 multiversedeb 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 partnerdeb http://security.ubuntu.com/ubuntu xenial-security main restricted# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricteddeb http://security.ubuntu.com/ubuntu xenial-security universe# deb-src http://security.ubuntu.com/ubuntu xenial-security universedeb http://security.ubuntu.com/ubuntu xenial-security multiverse# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

可以看到,官方的默认源是来自美国的 us.archive.ubuntu.com 和 security.ubuntu.com。那么我们怎么样换成速度更快的国内源呢?很简单,把 /etc/apt/sources.list 文件复制备份一下,然后把原来的内容修改成国内源的网址即可。以下步骤说明以阿里云的源为例:

1. 复制备份原来的配置文件

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

2. 使用你喜欢的文本编辑器如 vi/vim/nano,打开 sources.list 文件,把原来的内容替换成以下内容:

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse##测试版源 deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse#  源码 deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse## 测试版源 deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse# Canonical  合作伙伴和附加 deb http://archive.canonical.com/ubuntu/ xenial partnerdeb http://extras.ubuntu.com/ubuntu/ xenial main

3. 运行 sudo apt-get update 命令,更新软件列表,以后就可以使用阿里云提供的快速源了。同样的方法,也可以替换为网易源、搜狐源、中科大源、清华大学源等。

读到这里,这篇“如何更换 Ubuntu 软件源”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-13发表,共计4694字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)