ubuntu怎樣添加源
Ubuntu和Debian一樣使用Apt高級包管理系統,可以很方便的進行在線安裝、升級、卸載。但是Ubuntu和Debian所使用的源(source)是不同的。
Ubuntu安裝完後,默認使用的可能是國外的源,速度可能比較慢。現在國內也有很多服務器提供國外源的鏡像,可以使得Ubuntu軟件包的安裝、升級快很多。
源可以在ubuntu的菜單:系統管理=>軟件源配置中圖形化的配置。但是用命令行配置可以說的更清楚一些。使用一個編輯工具打開/etc/apt/sources.list文件(比如這裏的gedit):
複製內容到剪貼板
代碼:
sudo gedit /etc/apt/souces.list
也可以用其他編輯器,在純字符模式下可以用:
複製內容到剪貼板
代碼:
sudo gedit /etc/apt/sources.list
這個文件裏面的內容可以放心的全部刪除,然後用如下的內容代替(以7.04 feisty版爲例):
複製內容到剪貼板
代碼:
## cn.archive.ubuntu.com
deb http://cn.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ feisty-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ feisty-security main restricted universe multiverse
其他版本的ubuntu可以把其中的feisty替換成相應版本的名字,比如dapper、edgy、gutsy等。
也可以用如下的cn99的源:
複製內容到剪貼板
代碼:
deb http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse
兩 個源選一個就可以了。以上配置的是Ubuntu官方的源。而中國的ubuntu社區根據中國用戶的一些需要,把中國用戶一些常用的軟件放在ubuntu- cn的源當中。但是這個源當中的很多軟件包有版權問題,所以不能進入官方的源。要添加ubuntu-cn的源,可以在前面內容的基礎上再添加一行:
複製內容到剪貼板
代碼:
deb http://cn.archive.ubuntu.com/ubuntu-cn/ feisty main restricted universe multiverse
或者
複製內容到剪貼板
代碼:
deb http://ubuntu.cn99.com/ubuntu-cn/ feisty main restricted universe multiverse
如果需要下載源代碼,可以加上源代碼的源,就是將每行開頭的deb改成deb-src就可以了,比如
複製內容到剪貼板
代碼:
deb-src http://cn.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ feisty-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ feisty-security main restricted universe multiverse
如果還有其他的第三方的源,可以在這個文件裏面繼續添加。比如要安裝google提供的picasa或者googleearth可以添加如下的一行就可以了:
複製內容到剪貼板
代碼:
deb http://dl.google.com/linux/deb/ stable non-free
注意不要輕信第三方的源,因爲惡意製作的源服務器可能存在惡意軟件,隨意添加他們可能會給系統帶來安全問題。