本文记录 Ubuntu 更换镜像源的过程.
使用清华 TUNA 镜像.
1. 受支持的 Ubuntu 更换软件源
对长期支持版本,以 Ubuntu16.04 为例,使用如下步骤修改镜像源.
1. 备份 /etc/apt/sources.list
.
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2. 编辑 /etc/apt/sources.list
.
打开 /etc/apt/sources.list
:
sudo vim /etc/apt/sources.list
在命令模式下输入 ggdG,删除全部内容.
在输入模式下,粘贴复制下列内容:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src 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-src 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-src 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
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
Ubuntu 其它版本参看Ubuntu 镜像使用帮助.
保存退出.
3. 更新
sudo apt update
或者
sudo apt-get update
4. 国内其它镜像源
清华源 | TUNA |
科大源 | UTSC |
阿里源 | aliyun mirror |
网易源 | 163 mirror |
一般点击
?
或help
查看具体的编辑内容
2. 不受支持的 Ubuntu 更换软件源
对已经过期的LTS版本或者非LTS版本等不受支持的 Ubuntu 系统,以 Ubuntu12.04 为例,按照下面所述修改镜像源.
修改 /etc/apt/sources.list
:
- 将软件源地址修改为 http://old-releases.ubuntu.com/ubuntu(Ubuntu 官方 old 源)或者 http://mirrors.ustc.edu.cn/ubuntu-old-releases/ubuntu(科大 old 源).
- 将 Ubuntu 版本代号改为
precise
.
# 默认注释了源码仓库,如有需要可自行取消注释
deb http://old-releases.ubuntu.com/ubuntu/ precise main restricted universe multiverse
# deb-src http://old-releases.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
# deb-src http://old-releases.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
# deb-src http://old-releases.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
# deb-src http://old-releases.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
# 预发布软件源,不建议启用
# deb http://old-releases.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
# deb-src http://old-releases.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
其它操作相同.