【ubuntu】更換下載源


ubuntu,我們在使用apt新裝軟件的時候,會使用官方的網站去下載軟件,但是會因為國內的轉接點太多,而導致下載的速度非常慢 ,我們可以通過換成一些中間的節點來進行下載,比如阿里源,中科大源,清華源等等,這樣的網站,他們會定時和官方的源進行同步和更新,而我們直接同步他們,速度就會比直接同步官方的源快很多,這樣能夠大大增加我們的下載軟件的速度。

一、ubuntu系統更換源

文件存放在apt文件夾內

所以先進入文件夾

cd /etc/apt

在修改之前對文件進行備份

sudo cp sources.list sources.list.bak

對文件進行修改

sudo vi sources.list

 

二、刪除掉sources.list的其他內容,任意選擇一種源的內容復制粘貼進去,保存,例如,選擇阿里源

2.1阿里源

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

今天在用apt-get update更新時一直失敗,報的錯誤為”Failed to fetch 404 Not Found”,因為我的鏡像改為了mirrors.aliyun.com 我試着ping了一下發現能通,所以就在網上查找了下答案

大部分的解釋是因為每個Ubuntu版本都有生命結束周期(EOL)時間;常規的Ubuntu發行版提供18個月的支持,而LTS(長期支持)版本則長達3年(服務器版本)和5年(桌面版本)。當某個Ubuntu版本達到生命結束周期時,其倉庫就不能再訪問了,你也不能再從Canonical獲取任何維護更新和安全補丁。在撰寫本文時,Ubuntu 13.04(急切的浣熊)已經達到了它的生命結束周期。

如果你所使用的Ubuntu系統已經被結束生命周期,你就會從apt-get或aptitude得到以下404錯誤,因為它的倉庫已經被遺棄了。

解決方法為講/etc/apt/sources.list路徑下的源替換為舊版本倉庫的源。

BUT,我的鏡像是阿里雲的鏡像,貌似沒有什么舊版本的路徑,我就在/etc/apt/sources.list路徑下刪除,重新替換為下面的路徑

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

 之后再apt-get就可以了 

 

2.2東北大學源

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse

deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties

deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse

2.3清華大學源

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

 

三、更新下載源

sudo apt-get update

 四、輸入過程中可能會出現的問題

root@ubuntu:/etc/apt# apt-get update
Err:1 http://mirrors.aliyun.com/ubuntu xenial InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:2 http://mirrors.aliyun.com/ubuntu xenial-updates InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:3 http://mirrors.aliyun.com/ubuntu xenial-backports InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:4 http://mirrors.aliyun.com/ubuntu xenial-security InRelease
Temporary failure resolving 'mirrors.aliyun.com'
Err:5 http://archive.canonical.com/ubuntu xenial InRelease
Temporary failure resolving 'archive.canonical.com'
Err:6 http://archive.ubuntu.com/ubuntu xenial InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done

 

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/perl/perl-base_5.22.1-9ubuntu0.5_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/p/perl/perl-modules-5.22_5.22.1-9ubuntu0.5_all.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.23-0ubuntu10_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/d/db5.3/libdb5.3_5.3.28-11ubuntu0.1_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g_1.2.8.dfsg-2ubuntu4.1_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/i/init-system-helpers/init-system-helpers_1.29ubuntu4_all.deb Temporary failure resolving 'us.archive.ubuntu.com'

E: Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/i/init-system-helpers/init_1.29ubuntu4_amd64.deb Temporary failure resolving 'us.archive.ubuntu.com'

 

vim /etc/resolv.conf
nameserver 127.0.1.1
nameserver 192.168.23.1  
nameserver 221.130.33.52  
nameserver 169.95.1.1  
nameserver 114.114.114.114 

    在Ubuntu操作系統中,使用apt-get命令安裝所需的開發軟件非常方便,但也有不少時候由於鏈接不上軟件源而不能正常安裝,於是很多人都會想到使用sudo apt-get update命令來更新軟件源,而恰恰這時屋漏偏逢連夜雨,更新命令也不能正常工作,出現大量“Failed to fetch”的錯誤,出現failed to fetch一般來說是要去更新我們的DNS 再次執行 更新操作

sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade

 

 其他一些命令

sudo apt-get update  更新源
sudo apt-get install package 安裝包
sudo apt-get remove package 刪除包
sudo apt-cache search package 搜索軟件包
sudo apt-cache show package  獲取包的相關信息,如說明、大小、版本等
sudo apt-get install package --reinstall  重新安裝包
sudo apt-get -f install  修復安裝
sudo apt-get remove package --purge 刪除包,包括配置文件等
sudo apt-get build-dep package 安裝相關的編譯環境
sudo apt-get upgrade 更新已安裝的包
sudo apt-get dist-upgrade 升級系統
sudo apt-cache depends package 了解使用該包依賴那些包
sudo apt-cache rdepends package 查看該包被哪些包依賴
sudo apt-get source package  下載該包的源代碼
sudo apt-get clean && sudo apt-get autoclean 清理無用的包
sudo apt-get check 檢查是否有損壞的依賴

  

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM