Linux入门教程:Ubuntu修改apt源,我们可以更换apt源


Ubuntu官方的apt源在国内下载软件包时,下载速度慢,有时候甚至无法下载。我们可以更换apt源为国内的apt源,比如说清华大学开源软件源。本文以清华大学开源软件源为例,其他的apt源请自行查找。

一、备份/etc/apt/sources.list文件

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

二、打开Ubuntu 镜像使用帮助,选择对应版本的软件源(以18.04 LTS为例)

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src 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-src 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-src 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
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

三、编辑源列表文件

nano /etc/apt/sources.list

四、读取软件包列表(更新apt源)

apt-get update

相关内容