ubuntu apt源的添加和使用【整理】
【备份当前的源列表文件】
sudo cp -p /etc/apt/sources.list /etc/apt/sources.list_backup
【用文本编辑器编辑源列表文件】
Ubuntu (GNOME) 用户:
sudo gedit /etc/apt/sources.list
Kubuntu (KDE) 用户:
sudo kate /etc/apt/sources.list
其他系统用户,比如Xubuntu:
sudo nano /etc/apt/sources.list
以下面这些行的内容作为模板来引导自己编辑sources.list中的软件源
你可以试着用以下这些行来代替sources.list中当前的内容
要想使用你本地的镜像,可以在archive.ubuntu.com之前加入"cc.",其中cc = 你所在国家的代码
例如 deb http://lv.archive.ubuntu.com/ubuntu feisty main restricted universe multiverse
下面是我从网络上找到的一些源,以及我本地【中国 苏州】到该源的速度,以供大家参考。
根据速度快慢排序如下:
———————————————————————————————
1.江苏常州电信
deb http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-security main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-updates main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.cn99.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy multiverse
速度测试结果:
C:Documents and SettingsAdministrator>ping ubuntu.cn99.com
Pinging mirrors.cn99.com [222.185.245.42] with 32 bytes of data:
Reply from 222.185.245.42: bytes=32 time=24ms TTL=58
Reply from 222.185.245.42: bytes=32 time=20ms TTL=58
Reply from 222.185.245.42: bytes=32 time=41ms TTL=58
Reply from 222.185.245.42: bytes=32 time=18ms TTL=58
Ping statistics for 222.185.245.42:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 18ms, Maximum = 41ms, Average = 25ms
2.浙江杭州电信 mirror.lupaworld.com
deb http://mirror.lupaworld.com/ubuntu/archive/ dapper main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/archive/ dapper-security main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/archive/ dapper-updates main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/archive/ dapper-backports main restricted universe multiverse
deb http://mirror.lupaworld.com/ubuntu/ubuntu-cn/ dapper main restricted universe multiverse
速度测试结果:
C:Documents and SettingsAdministrator>ping mirror.lupaworld.com
Pinging mirror.lupaworld.com [61.164.52.148] with 32 bytes of data:
Reply from 61.164.52.148: bytes=32 time=42ms TTL=55
Reply from 61.164.52.148: bytes=32 time=47ms TTL=55
Reply from 61.164.52.148: bytes=32 time=45ms TTL=55
Reply from 61.164.52.148: bytes=32 time=42ms TTL=55
Ping statistics for 61.164.52.148:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 42ms, Maximum = 47ms, Average = 44ms
3.cn.archive.ubuntu.com
速度测试结果:
C:Documents and SettingsAdministrator>ping cn.archive.ubuntu.com
Pinging mirrors.shlug.org [222.73.255.64] with 32 bytes of data:
Request timed out.
Reply from 222.73.255.64: bytes=32 time=50ms TTL=56
Reply from 222.73.255.64: bytes=32 time=54ms TTL=56
Reply from 222.73.255.64: bytes=32 time=52ms TTL=56
Ping statistics for 222.73.255.64:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 54ms, Average = 52ms
4.中国台湾大学
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-updates main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-updates main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-backports main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-backports main restricted universe multiverse
deb http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-security main restricted universe multiverse
deb-src http://ubuntu.csie.ntu.edu.tw/ubuntu/ dapper-security main restricted universe multiverse
速度测试结果:
C:Documents and SettingsAdministrator>ping ubuntu.csie.ntu.edu.tw
Pinging mirror.csie.ntu.edu.tw [140.112.30.75] with 32 bytes of data:
Reply from 140.112.30.75: bytes=32 time=67ms TTL=51
Reply from 140.112.30.75: bytes=32 time=55ms TTL=51
Reply from 140.112.30.75: bytes=32 time=67ms TTL=51
Reply from 140.112.30.75: bytes=32 time=65ms TTL=51
Ping statistics for 140.112.30.75:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 55ms, Maximum = 67ms, Average = 63ms
5.上海电信
deb http://mirror.rootguide.org/ubuntu/ feisty main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ feisty main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ feisty-updates main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ feisty-updates main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ feisty-backports main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ feisty-backports main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ feisty-security main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ feisty-security main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ feisty-proposed main multiverse restricted universe
deb-src http://mirror.rootguide.org/ubuntu/ feisty-proposed main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu-cn/ feisty main multiverse restricted universe
C:Documents and SettingsAdministrator>ping mirror.rootguide.org
Pinging mirror.rootguide.org [61.129.34.45] with 32 bytes of data:
Reply from 61.129.34.45: bytes=32 time=80ms TTL=56
Reply from 61.129.34.45: bytes=32 time=115ms TTL=56
Reply from 61.129.34.45: bytes=32 time=97ms TTL=56
Reply from 61.129.34.45: bytes=32 time=82ms TTL=56
Ping statistics for 61.129.34.45:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 80ms, Maximum = 115ms, Average = 93ms
6.清华大学计算机系学生科协(教育网用户推荐)
deb http://mirror.net9.org/ubuntu/ dapper main multiverse restricted universe
deb http://mirror.net9.org/ubuntu/ dapper-backports main multiverse restricted universe
deb http://mirror.net9.org/ubuntu/ dapper-proposed main multiverse restricted universe
deb http://mirror.net9.org/ubuntu/ dapper-security main multiverse restricted universe
deb http://mirror.net9.org/ubuntu/ dapper-updates main multiverse restricted universe
deb http://mirror.net9.org/ubuntu-cn/ dapper main multiverse restricted universe
C:Documents and SettingsAdministrator>ping mirror.net9.org
Pinging mirror.net9.org [59.66.131.167] with 32 bytes of data:
Reply from 59.66.131.167: bytes=32 time=257ms TTL=49
Reply from 59.66.131.167: bytes=32 time=262ms TTL=49
Reply from 59.66.131.167: bytes=32 time=268ms TTL=49
Reply from 59.66.131.167: bytes=32 time=265ms TTL=49
Ping statistics for 59.66.131.167:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 257ms, Maximum = 268ms, Average = 263ms
7.# 传说中的电子科大
deb http://ubuntu.uestc.edu.cn/ubuntu hardy main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu hardy-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu hardy-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu hardy-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu hardy-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu hardy main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu hardy-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu hardy-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu hardy-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu hardy-updates main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu-cn hardy main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntustudio hardy main
C:Documents and SettingsAdministrator>ping ubuntu.uestc.edu.cn
Pinging ubuntu.uestc.edu.cn [202.115.22.208] with 32 bytes of data:
Reply from 202.115.22.208: bytes=32 time=308ms TTL=49
Reply from 202.115.22.208: bytes=32 time=309ms TTL=49
Reply from 202.115.22.208: bytes=32 time=300ms TTL=49
Reply from 202.115.22.208: bytes=32 time=252ms TTL=49
Ping statistics for 202.115.22.208:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 252ms, Maximum = 309ms, Average = 292ms
8.
deb http://archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ dapper main restricted universe multiverse
C:Documents and SettingsAdministrator>ping archive.ubuntu.com
Pinging archive.ubuntu.com [91.189.88.46] with 32 bytes of data:
Reply from 91.189.88.46: bytes=32 time=437ms TTL=48
Reply from 91.189.88.46: bytes=32 time=442ms TTL=48
Reply from 91.189.88.46: bytes=32 time=443ms TTL=48
Reply from 91.189.88.46: bytes=32 time=444ms TTL=48
Ping statistics for 91.189.88.46:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 437ms, Maximum = 444ms, Average = 441ms
9.
deb http://us.archive.ubuntu.com/ubuntu dapper main restricted
deb-src http://us.archive.ubuntu.com/ubuntu dapper main restricted
deb http://us.archive.ubuntu.com/ubuntu dapper-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu dapper-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu dapper universe
deb http://us.archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe
deb http://archive.ubuntu.com/ubuntu dapper multiverse
deb-src http://archive.ubuntu.com/ubuntu dapper multiverse
deb http://archive.ubuntu.com/ubuntu dapper-backports main restricted universe multiverse
C:Documents and SettingsAdministrator>ping us.archive.ubuntu.com
Pinging us.archive.ubuntu.com [91.189.88.31] with 32 bytes of data:
Reply from 91.189.88.31: bytes=32 time=452ms TTL=48
Reply from 91.189.88.31: bytes=32 time=451ms TTL=48
Reply from 91.189.88.31: bytes=32 time=452ms TTL=48
Reply from 91.189.88.31: bytes=32 time=486ms TTL=48
Ping statistics for 91.189.88.31:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 451ms, Maximum = 486ms, Average = 460ms
C:Documents and SettingsAdministrator>ping security.ubuntu.com
Pinging security.ubuntu.com [91.189.88.37] with 32 bytes of data:
Reply from 91.189.88.37: bytes=32 time=456ms TTL=48
Reply from 91.189.88.37: bytes=32 time=459ms TTL=48
Reply from 91.189.88.37: bytes=32 time=460ms TTL=48
Reply from 91.189.88.37: bytes=32 time=459ms TTL=48
Ping statistics for 91.189.88.37:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 456ms, Maximum = 460ms, Average = 458ms
10.上海交通大学(教育网用户推荐):
deb http://ftp.sjtu.edu.cn/ubuntu/ dapper main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ dapper-backports main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ dapper-proposed main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ dapper-security main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu/ dapper-updates main multiverse restricted universe
deb http://ftp.sjtu.edu.cn/ubuntu-cn/ dapper bleeding main multiverse restricted universe
C:Documents and SettingsAdministrator>ping ftp.sjtu.edu.cn
Pinging ftp.sjtu.edu.cn [202.38.97.230] with 32 bytes of data:
Request timed out.
Reply from 202.38.97.230: bytes=32 time=857ms TTL=53
Reply from 202.38.97.230: bytes=32 time=856ms TTL=53
Request timed out.
Ping statistics for 202.38.97.230:
Packets: Sent = 4, Received = 2, Lost = 2 (50% loss),
Approximate round trip times in milli-seconds:
Minimum = 856ms, Maximum = 857ms, Average = 856ms
———————————————————————————————
其他还有一些地址,包括中科大,厦大,兰州大学等,由于我这ping都是time out,所以就不列出来了,需要的自己去这看:
【保存编辑完毕的文件】
下载需要的 gpg keys; 例如, 使用下面的命令以得到 PLF 软件源的 gpg key:
wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add –
如果你希望尝试 E17 beta, 也需要下载其 gpg key:
wget -q http://lut1n.ifrance.com/repo_key.asc -O- | sudo apt-key add –
【更新软件列表】(添加/删除源後必须进行的操作)
sudo aptitude update
【更新已安装的软件包】
sudo aptitude upgrade
【更新整个系统】
sudo aptitude dist-upgrade
你也可以生成自己的sources.list,并且可在下面的网址找到其他软件源: http://www.ubuntulinux.nl/source-o-matic
只有在你知道自己在做什么的前提下才能修改Ubuntu默认的 sources.list。将不同软件源混杂在一起可能使你的系统崩溃。
【从源码编译安装软件】
在进行源码编译安装前请确认已经建立好必要的编译环境 (比如安装必须的libraries, compilers, headers)
sudo aptitude install build-essential
sudo aptitude install linux-headers-`uname -r`
解压源码包(请参阅上文各种格式压缩包的操作)
tar xvzf package.tar.gz
开始编译工作:
cd /path/to/extracted/package
./configure
make
make install
如果可以正常编译/安装/使用该软件,可以考虑将它制作成deb包,以供将来使用(但用下面方法制作出来的deb包尽量不要提供给他人使用) 安装打包工具:
sudo aptitude install checkinstall
用"checkinstall"重建编译软件包:
cd /path/to/extracted/package
./configure
make
checkinstall
备份好最後得到的.deb格式的软件包,它可以通过下面的方法进行安装:
sudo dpkg -i package.deb
注意:这里只是讲了最基本的操作,由于各种软件编译所需的开发包,所需用到的编译参数各不相同,故在实际运用时需随机应变.
手动更新系统
sudo aptitude update
sudo aptitude upgrade
sudo aptitude dist-upgrade
转载请注明:在路上 » ubuntu apt源的添加和使用【整理】