apt-get 國內源詳解

一、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-hk/n/343251.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
NWLOL的頭像NWLOL
上一篇 2025-02-11 14:15
下一篇 2025-02-11 14:16

相關推薦

  • Elasticsearch API使用用法介紹-get /_cat/allocation

    Elasticsearch是一個分佈式的開源搜索和分析引擎,支持全文檢索和數據分析,並且可伸縮到上百個節點,處理PB級結構化或非結構化數據。get /_cat/allocation…

    編程 2025-04-28
  • SpringBoot Get方式請求傳參用法介紹

    本文將從以下多個方面對SpringBoot Get方式請求傳參做詳細的闡述,包括URL傳參、路徑傳參、請求頭傳參、請求體傳參等,幫助讀者更加深入地了解Get請求方式下傳參的相關知識…

    編程 2025-04-27
  • 如何在Python中配置國內鏡像源

    如果你使用Python進行開發,那麼肯定會遇到下載模塊或庫速度慢的情況。這時,我們就可以配置國內鏡像源來解決這一問題。本文將會從多個方面來介紹如何配置國內鏡像源。 一、pip配置國…

    編程 2025-04-27
  • HTTP請求方式的選擇:POST還是GET?

    對於使用xxl-job進行任務調度的開發者,通常需要發送HTTP請求來執行一些任務。但是在發送請求時,我們總是會遇到一個問題:是使用POST還是GET?下面將從多個方面對這個問題進…

    編程 2025-04-27
  • Linux sync詳解

    一、sync概述 sync是Linux中一個非常重要的命令,它可以將文件系統緩存中的內容,強制寫入磁盤中。在執行sync之前,所有的文件系統更新將不會立即寫入磁盤,而是先緩存在內存…

    編程 2025-04-25
  • 神經網絡代碼詳解

    神經網絡作為一種人工智能技術,被廣泛應用於語音識別、圖像識別、自然語言處理等領域。而神經網絡的模型編寫,離不開代碼。本文將從多個方面詳細闡述神經網絡模型編寫的代碼技術。 一、神經網…

    編程 2025-04-25
  • Python輸入輸出詳解

    一、文件讀寫 Python中文件的讀寫操作是必不可少的基本技能之一。讀寫文件分別使用open()函數中的’r’和’w’參數,讀取文件…

    編程 2025-04-25
  • nginx與apache應用開發詳解

    一、概述 nginx和apache都是常見的web服務器。nginx是一個高性能的反向代理web服務器,將負載均衡和緩存集成在了一起,可以動靜分離。apache是一個可擴展的web…

    編程 2025-04-25
  • git config user.name的詳解

    一、為什麼要使用git config user.name? git是一個非常流行的分佈式版本控制系統,很多程序員都會用到它。在使用git commit提交代碼時,需要記錄commi…

    編程 2025-04-25
  • Linux修改文件名命令詳解

    在Linux系統中,修改文件名是一個很常見的操作。Linux提供了多種方式來修改文件名,這篇文章將介紹Linux修改文件名的詳細操作。 一、mv命令 mv命令是Linux下的常用命…

    編程 2025-04-25

發表回復

登錄後才能評論