一、apt-get 國內源優勢
1、加快軟體安裝速度
使用國內源下載軟體包可大大提高軟體安裝速度,從而縮短等待時間。
2、降低安裝軟體失敗率
使用海外源安裝軟體時,由於網路原因可能會出現安裝失敗的情況。而國內源在兼容性、穩定性等方面優於海外源,能夠減少安裝失敗的概率。
3、保證系統安全性
國內源由國內公司維護,相較於海外源更有保障,能夠保證從源下載的軟體包是安全可靠的。
二、添加國內源方法
1、備份原源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、打開源設置文件
vi /etc/apt/sources.list
3、將原文件的內容清空,寫入以下內容
# 默認注釋了源碼鏡像以提高 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 deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
4、保存退出
按下 Esc,輸入 :wq,然後回車即可保存並退出。
5、更新源列表
sudo apt-get update
三、在Ubuntu中使用aliyun代替默認的mirrors.tuna.tsinghua.edu.cn
1、備份原源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、打開源設置文件
sudo vim /etc/apt/sources.list
3、將默認的mirrors.tuna.tsinghua.edu.cn替換為aliyun
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
4、保存退出
按下 Esc,輸入 :wq,然後回車即可保存並退出。
5、更新源列表
sudo apt-get update
四、總結
本文詳細闡述了apt-get 國內源的優勢、添加國內源的方法以及在Ubuntu中使用aliyun代替默認的mirrors.tuna.tsinghua.edu.cn。通過使用國內源,我們可以加速軟體下載,降低安裝失敗率,保證系統安全性。
原創文章,作者:NWLOL,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/343251.html