为ubuntu更新提速:将更新源改为国内源

为ubuntu更新提速:将更新源改为国内源

知识分子没文化
2021-01-27 / 0 评论 / 330 阅读 / 正在检测是否收录...

目录:

环境说明:

系统版本:ubuntu 18.04

以下方法适用于ubuntu 18.0.4(版本号为bionic),若为ubuntu其他版本,将源链接中的bionic改为其他版本号即可:

step 1:获取ubuntu版本号

lsb_release -a

其中的 Codename 一项为版本号

step 2:备份原文件(可选)

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

step 3:修改源文件

ubuntu 的下载源更新源等存放在 /etc/apt/sources.list

nano编辑 /etc/apt/sources.list

sudo nano /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-backports main restricted universe multiverse
##測試版源
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed 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-backports main restricted universe multiverse
##測試版源
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse


# 清华大学源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 源碼
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
##測試版源
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

ctrl + O保存,ctrl + X退出即可

step 4:更新软件列表和升级

在终端上执行以下命令更新软件列表,检测出可以更新的软件:

sudo apt-get update

在终端上执行以下命令进行软件更新:

sudo apt-get upgrade

换源之后,都是从国内镜像站获取软件包,所以此时更新时的速度会比换源之前快上很多。

0

评论 (0)

取消