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

2023-07-01 15:06:12 浏览数 (1)

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

step 1:获取ubuntu版本号
代码语言:javascript复制
lsb_release -a

其中的 Codename 一项为版本号

step 2:备份原文件(可选)
代码语言:javascript复制
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
step 3:修改源文件

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

nano编辑 /etc/apt/sources.list

代码语言:javascript复制
sudo nano /etc/apt/sources.list

下面包含了阿里云源和清华大学源,在打开文件后,注释或者清空里面的内容,任选一个国内源复制进去:

代码语言:javascript复制
# 阿里云源
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:更新软件列表和升级

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

代码语言:javascript复制
sudo apt-get update

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

代码语言:javascript复制
sudo apt-get upgrade

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

0 人点赞