Ubuntu切换数据源
Ubuntu安裝完畢之后,默認(rèn)的源是Ubuntu自己的,但畢竟Ubuntu服務(wù)器在國(guó)外,我們?cè)L問(wèn)起來(lái)會(huì)比較慢,可以將軟件源切換為國(guó)內(nèi)源,比如:阿里源,清華源,中科大源等等。在這邊以清華源為例,其它源也是一樣的道理。
1 切換源之前先把配置文件備份一份:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2 找到清華源官網(wǎng):
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
一定要選擇與自己版本相對(duì)應(yīng)的源,比如當(dāng)前使用Ubuntu20.04,最好使用此版本的源,否則有可能會(huì)有意料不到的問(wèn)題,良許就吃過(guò)這方面的虧。
網(wǎng)絡(luò)上也有很多教你換源的帖子,但都是直接給出內(nèi)容,有可能源與自己的版本不一致,所以最好自己去官網(wǎng)復(fù)制。
3.將之前的源全部刪除
echo ” > sources.list
4.編輯新源文件
nano sources.list
5.加入新的數(shù)據(jù)源(清華數(shù)據(jù)源)
# 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# 預(yù)發(fā)布軟件源,不建議啟用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse6.使用新源替換掉原來(lái)的源(一定要加sudo):
sudo vi /etc/apt/sources.list
7.然后更新軟件包緩存:
sudo apt update
這個(gè)命令,會(huì)訪問(wèn)源列表里的每個(gè)網(wǎng)址,并讀取軟件列表,然后保存在本地電腦。
8.通常我們會(huì)緊跟著再執(zhí)行命令:
sudo apt-get upgrade
這個(gè)命令,會(huì)把本地已安裝的軟件,與剛下載的軟件列表里對(duì)應(yīng)軟件進(jìn)行對(duì)比,如果發(fā)現(xiàn)已安裝的軟件版本太低,就會(huì)提示你更新。
9.備用數(shù)據(jù)源【阿里】
在下面網(wǎng)站查找最新數(shù)據(jù)源
https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.b5371b11tio0iu
Ubuntu 14.04.5 LTS為例,最后的效果如下:
deb https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiversedeb https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse## Not recommended # deb https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse # deb-src https://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverseubuntu 16.04 配置如下
deb http://mirrors.aliyun.com/ubuntu/ xenial main deb-src http://mirrors.aliyun.com/ubuntu/ xenial maindeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates maindeb http://mirrors.aliyun.com/ubuntu/ xenial universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security main deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universeubuntu 18.04(bionic) 配置如下
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverseubuntu 20.04(focal) 配置如下
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backport總結(jié)
以上是生活随笔為你收集整理的Ubuntu切换数据源的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Ubuntu安装教程【超多图】
- 下一篇: openharmony编译报错ubunt