編碼的世界 / 優質文選 / 女人

手摸手教程之ubuntu20.04更改國內鏡像源(附其他版本ubuntu換源教程,最新詳細教程)


2022年8月02日
-   

windows10自帶ubuntu系統更新到ubuntu20.04版本啦!默認的軟件更新源是國外的,速度超級慢,用"apt install"安裝軟件時各種網絡問題也是層出不窮(上次安裝ubuntu後忘記修改源結果導致N多次安裝半小時然後失敗…親身經歷了這種苦,回過頭發現修改源之後很多網絡問題迎刃而解),因此我們需要更換成國內鏡像源,然後正常安裝和更新軟件。
unbuntu版本名
修改源之前提示大家先查看版本名,ubuntu20.04對應的是“focal”,也就是我下面鏡像源中提到的。“eoan”代表ubuntu19.10,“xenial”代表ubuntu16.04,“bionic”代表ubuntu18.04,“disco”代表ubuntu19.04,但是最好還是查看自己的版本名,並更改相應位置的ubuntu版本名。 用以下命令查看版本名:
lsb_release -c

得到的就是你的版本名啦!比如我的就是:
備份鏡像源
首先備份原來的軟件源並另存:
sudo cp -v /etc/apt/sources.list /etc/apt/sources.list.backup

修改鏡像源
執行chmod命令更改文件權限使軟件源文件可編輯:
sudo chmod 777 /etc/apt/sources.list

之後通過gedit命令編輯軟件源:
sudo gedit /etc/apt/sources.list

如果報錯提示:
sudo: gedit: command not found

那麼直接使用vim修改:
vim /etc/apt/sources.list

順便提一下vim的使用:進入後按i進入編輯模式(即INSERT插入),編輯完後先按Esc退出編輯模式,然後輸入 :wq 退出即可。 打開源文件後,進入編輯模式將所有的代碼刪乾淨,然後複制粘貼你需要的鏡像源(下面的鏡像源任選一個就可以,我用的是阿裏雲的鏡像源,這裏記得把ubuntu版本名替換為你在自己系統上查看到的版本名): 編輯完後先按Esc退出編輯模式,輸入 :wq 退出。
可選鏡像源
當然你也可以選擇其他比如中科大、163的,我用過的阿裏雲和清華的都還挺穩定,所以列出這兩個的。 阿裏雲源:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

清華源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse

修改完軟件源後,更新軟件列表和軟件:
sudo apt update

sudo apt upgrade

然後大功告成!如果還有什麼問題,留言與我交流!

熱門文章