使用Ubuntu时,apt-get是很方便的一个工具,但默认使用的欧洲源,国内速度太慢。可以把更新源换成速度更快的镜像,并使用apt-fast去多线程更新。
1、备份更新源文件
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、打开更新源文件编辑
$ sudo gedit /etc/apt/sources.list
3、根据UBUNTU版本,把全部内容替换为如下内容
版本11.04
deb http://ubuntu.uestc.edu.cn/ubuntu/ natty main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ natty-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ natty-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ natty-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ natty-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ natty main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ natty-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ natty-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ natty-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ natty-updates main restricted universe multiverse
版本11.10
deb http://ubuntu.uestc.edu.cn/ubuntu/ oneiric main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ oneiric main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ oneiric-updates main restricted universe multiverse
版本12.04
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
4、更新系统
$ sudo apt-get update
$ sudo apt-get dist-upgrade
5、安装apt-fast
sudo add-apt-repository ppa:apt-fast/stable
用命令更新源:
sudo apt-get update
使用命令安装apt-fast:
sudo apt-get install apt-fast
在安装期间,它将要求你输入下载包的最大并发链接数。
在下一个对话框里面,会问你是否要禁止apt-fast的确认对话框。选择No并继续安装。如果你选择Yes,apt-fast在安装软件包时不会问你确认与否。
我发现 aria2 下载管理器已经随着apt-fast的安装而自动安装。所以,你不必单独安装aria2。
如果你想重新配置apt-fast选项,你可以使用命令:
sudo dpkg-reconfigure apt-fast
用法
与apt-get功能相似,我们可以使用:
apt-fast install package apt-fast remove package apt-fast update apt-fast upgrade apt-fast dist-upgrade
及更多命令。
这是一个正在工作中的apt-fast包管理器:
创建别名(可选)
编辑 ~/.bashrc 文件在末尾添加下面这行。
alias apt-get='apt-fast'
或者简单运行以下命令在你的 ~/.bashrc 中添加它。
sudo echo "alias apt-get='apt-fast'" >> ~/.bashrc
从现在每当你运行apt-get命令去移除,更新和升级包时,它将在后台自动使用apt-fast。听起来很酷吧?
在测试期间,当下载包时我发现它与apt-get相比非常快。试一试,你一定会赞同我的看法。感谢阅读!!