今天晚上用官方源打算安裝東西的時候發現速度偏慢,哎,這么不靠譜,這不是逼我投向別人的懷抱嘛。開了N個網頁,總算搞清楚源是腫么回事了,果斷碼個總結!
一、軟件源的描述
軟件源就是一個應用程序安裝庫,很多很多的應用軟件都在這個庫里面。他可以是網絡服務器,是光盤,甚至是硬盤上的一個目錄。所以說要安裝好軟件且方便快捷,那首先得找到一個好的源,然后修改源文件更新下即可。
二、怎么修改源
源文件具體目錄:/etc/apt/sources.list
我的Ubuntu版本是11.10,剛安裝Ubuntu后sources.list文件內容如下:
1 #deb cdrom:[Ubuntu 11.10 _Oneiric Ocelot_ - Release i386 (20111012)]/ oneiric main restricted 2
3 # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
4 # newer versions of the distribution. 5 deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
6 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
7
8 ## Major bug fix updates produced after the final release of the 9 ## distribution. 10 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
11 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
12
13 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 14 ## team. Also, please note that software in universe WILL NOT receive any 15 ## review or updates from the Ubuntu security team. 16 deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
17 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric universe
18 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
19 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
20
21 ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 22 ## team, and may not be under a free licence. Please satisfy yourself as to 23 ## your rights to use the software. Also, please note that software in
24 ## multiverse WILL NOT receive any review or updates from the Ubuntu 25 ## security team. 26 deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
27 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
28 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
29 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
30
31 ## N.B. software from this repository may not have been tested as
32 ## extensively as that contained in the main release, although it includes 33 ## newer versions of some applications which may provide useful features. 34 ## Also, please note that software in backports WILL NOT receive any review 35 ## or updates from the Ubuntu security team. 36 deb http://us.archive.ubuntu.com/ubuntu/ oneiric-backports main restricted universe multiverse
37 deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-backports main restricted universe multiverse
38
39 deb http://security.ubuntu.com/ubuntu oneiric-security main restricted
40 deb-src http://security.ubuntu.com/ubuntu oneiric-security main restricted
41 deb http://security.ubuntu.com/ubuntu oneiric-security universe
42 deb-src http://security.ubuntu.com/ubuntu oneiric-security universe
43 deb http://security.ubuntu.com/ubuntu oneiric-security multiverse
44 deb-src http://security.ubuntu.com/ubuntu oneiric-security multiverse
45
46 ## Uncomment the following two lines to add software from Canonical's
47 ## 'partner' repository. 48 ## This software is not part of Ubuntu, but is offered by Canonical and the 49 ## respective vendors as a service to Ubuntu users. 50 # deb http://archive.canonical.com/ubuntu oneiric partner
51 # deb-src http://archive.canonical.com/ubuntu oneiric partner
52
53 ## This software is not part of Ubuntu, but is offered by third-party 54 ## developers who want to ship their latest software. 55 deb http://extras.ubuntu.com/ubuntu oneiric main
56 deb-src http://extras.ubuntu.com/ubuntu oneiric main
從文件內容我們可以看出官方源服務器位於美國,既然要找個速度快的,顯然得換個國內的源嘛。由於國內源眾多,據說163源蠻好,所以我選擇了163的源;不過據說骨頭源也蠻不錯,不過我已經選擇了163了,要專一啊!!反正好的源很多,看自己是電信的還是網通的,找個合適自己的最好!
OK,把原來的文件sources.list備份到sources.list-origin,我現在的sources.list的內容更換如下:
deb http://mirrors.163.com/ubuntu/ oneiric main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ oneiric-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ oneiric-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ oneiric-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ oneiric-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ oneiric main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ oneiric-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ oneiric-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ oneiric-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ oneiric-backports main restricted universe multiverse
OK,接下來簡要分析下sources.list的內容的意思,地址是http://mirrors.163.com/ubuntu/這個呢就是163的ubuntu源的服務器目錄,這個目錄下的內容我們還是要了解一下的,等會分析。然后有一個字符串引起我們的注意,而且至關重要,沒錯,就是:oneiric,這是Ubuntu 11.10的名字,具體有什么用還是等會帶來講解。
好的,接下來分析一下這個163服務器,進入這個服務器后(http://mirrors.163.com/ubuntu/),我們進入dists目錄,可以看到此時目錄下內容為:
../ hardy/ 14-Oct-2011 15:23 - hardy-backports/ 15-Jul-2012 14:54 - hardy-proposed/ 21-Jul-2012 15:30 - hardy-security/ 13-Jun-2012 15:09 - hardy-updates/ 21-Jul-2012 15:30 - lucid/ 14-Oct-2011 15:23 - lucid-backports/ 18-Jul-2012 15:24 - lucid-proposed/ 30-Jul-2012 14:57 - lucid-security/ 18-Jul-2012 15:23 - lucid-updates/ 22-Jul-2012 15:13 - maverick/ 14-Oct-2011 15:23 - maverick-backports/ 04-Apr-2012 14:59 - maverick-proposed/ 04-Apr-2012 14:59 - maverick-security/ 24-Mar-2012 14:57 - maverick-updates/ 24-Mar-2012 14:57 - natty/ 14-Oct-2011 15:23 - natty-backports/ 03-May-2012 15:32 - natty-proposed/ 31-Jul-2012 14:37 - natty-security/ 18-Jul-2012 15:23 - natty-updates/ 19-Jul-2012 15:18 - oneiric/ 14-Oct-2011 15:22 - oneiric-backports/ 04-Apr-2012 14:58 - oneiric-proposed/ 01-Aug-2012 15:21 - oneiric-security/ 18-Jul-2012 15:23 - oneiric-updates/ 21-Jul-2012 15:29 - precise/ 26-Apr-2012 14:30 - precise-backports/ 16-Jul-2012 15:00 - precise-proposed/ 01-Aug-2012 21:14 - precise-security/ 01-Aug-2012 21:14 - precise-updates/ 01-Aug-2012 21:14 - quantal/ 01-Aug-2012 21:14 - quantal-backports/ 27-Apr-2012 15:32 - quantal-proposed/ 01-Aug-2012 21:14 - quantal-security/ 27-Apr-2012 15:32 - quantal-updates/ 27-Apr-2012 15:32 -
那這個內容對我們有什么用呢?我們可以看到里面有hardy,lucid,oneiric等,這些呢,就是Ubuntu版本代號。每個Ubuntu版本都是有版本名的,不清楚可以進入百科查看hardy對應的是Ubuntu 8.04,而lucid對應的是Ubuntu 10.04。不同版本要求的的源文件的內容也是不同的,所以需要看清楚。
在此目錄中我們可以看到我們需要的版本11.10對應的源:oneiric,有了這個我們才能用163的源。
那假設我現在的Ubuntu版本是11.04,那我怎么修改sources.list的內容呢?很簡單,首先我們知道11.04的英文名是natty,我們從這個服務器可以看到有natty的目錄,那我們只需要把我剛更新的163的源文件中的oneiric改為natty,保存就可以了,方便吧!如果沒有natty,那么顯然修改了也找不到的,所以需要看清楚有沒對應自己Ubuntu版本的源。
三、修改源后操作
經過上面的操作,現在已經換好源了,肯定要讓它生效吧,按下面的步驟來即可:
1)sudo apt-get update #這一步是更新你的源列表,換源后必須執行
2)sudo apt-get dist-upgrade #這一步是更新軟件
OK,換源完成,要安裝什么東西輸入"sudo apt-get install [軟件名] "即可。而且速度蠻快!
本文完。