Ubuntu Server批量ping选择最快源
http://www.2cto.com/os/201102/83942.html
之前我在Ubuntu Server下用 sudo passwd root 启用了 root 用户,如果你没有启用,记得在命令前加"sudo"。
1、备份源列表文件 cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、用vim打开源列表文件 vim sources.list
3、按下Esc,然后全选并删除(ggdG),把新的源粘贴上去,保存退出(:wq)。我挨个ping了一下,觉得下面这2个最适合我,保存记录一下。"intrepid"是8.04的代号,如果是9.04的话改成"jaunty"就行了。
deb http://debian.ustc.edu.cn/Ubuntu/ intrepid main multiverse restricted universe
deb http://debian.ustc.edu.cn/Ubuntu/ intrepid-backports main multiverse restricted universe
deb http://debian.ustc.edu.cn/Ubuntu/ intrepid-proposed main multiverse restricted universe
deb http://debian.ustc.edu.cn/Ubuntu/ intrepid-security main multiverse restricted universe
deb http://debian.ustc.edu.cn/Ubuntu/ intrepid-updates main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/Ubuntu/ intrepid main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/Ubuntu/ intrepid-backports main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/Ubuntu/ intrepid-proposed main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/Ubuntu/ intrepid-security main multiverse restricted universe
deb-src http://debian.ustc.edu.cn/Ubuntu/ intrepid-updates main multiverse restricted universe
deb http://nz.archive.Ubuntu.com/ubuntu/ intrepid main restricted universe multiverse
deb http://nz.archive.Ubuntu.com/ubuntu/ intrepid-security main restricted universe multiverse
deb http://nz.archive.Ubuntu.com/ubuntu/ intrepid-updates main restricted universe multiverse
deb http://nz.archive.Ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse
deb http://nz.archive.Ubuntu.com/ubuntu/ intrepid-proposed main restricted universe multiverse
deb-src http://nz.archive.Ubuntu.com/ubuntu/ intrepid main restricted universe multiverse
deb-src http://nz.archive.Ubuntu.com/ubuntu/ intrepid-security main restricted universe multiverse
deb-src http://nz.archive.Ubuntu.com/ubuntu/ intrepid-updates main restricted universe multiverse
deb-src http://nz.archive.Ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse
deb-src http://nz.archive.Ubuntu.com/ubuntu/ intrepid-proposed main restricted universe multiverse
5、更新一下源 apt-get update
6、更新一下已安装的软件包 apt-get upgrade ,当然如果你想更新整个系统到最新发行版也可以 apt-get dist-upgrade
唔,为了方便以后测试源速度,干脆写一个脚本批量检测好了。
vim ping.sh 新建一个文件,写入以下脚本并保存。
#!/bin/sh
for ip in `cat testlist`
do
ping -c 5 -q $ip;
done
新建一个testlist文件保存源域名 vim testlist
nz.archive.Ubuntu.com
archive.Ubuntu.com
mirrors.163.com
cn.archive.Ubuntu.com
mirror.lupaworld.com
Ubuntu.realss.cn
Ubuntu.uestc.edu.cn
www.britepic.org
ftp.sjtu.edu.cn
debian.ustc.edu.cn
Ubuntu.csie.ntu.edu.tw
mirror.rootguide.org
tw.archive.Ubuntu.com
这里要先 chmod 755 ping.sh 给它执行权限,然后运行 ./ping.sh 即可,结果会显示在屏幕上。为了简单我给ping命令加了 -q 参数只显示最后的统计结果,连续 ping 5次。