推荐一个apt命令加速神器

推荐一个apt命令加速神器

有时候使用apt/apt-get命令时,会遇到下载比较慢的情况,特别是遇到有需要安装PPA上的软件的时候,这时就可以用apt-fast神器来对其进行加速。其实现原理是利用了aria2进行多线程下载,原理这里不做展开。仅讲解下如何在Ubuntu和在树莓派中安装该神器。

测试环境

基础系统:Ubuntu 18.04

树莓派系统:Debian armhf版本

Ubuntu上的安装方法

首先、添加apt-fast的安装源:

linux@ubuntu:~$ sudo add-apt-repository ppa:apt-fast/stable
 This PPA contains tested (stable) builds of apt-fast.
 More info: https://launchpad.net/~apt-fast/+archive/ubuntu/stable
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Get:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]                         
Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]                                      
Get:4 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB] 

其次、安装apt-fast软件包:

linux@ubuntu:~$ sudo apt-get install apt-fast
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  vim-runtime
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  aria2 libc-ares2
Suggested packages:
  aptitude zsh fish
The following NEW packages will be installed:
  apt-fast aria2 libc-ares2
0 upgraded, 3 newly installed, 0 to remove and 370 not upgraded.
Need to get 1,309 kB of archives.
After this operation, 5,040 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libc-ares2 amd64 1.14.0-1 [37.1 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 aria2 amd64 1.33.1-1 [1,236 kB]
Get:3 http://ppa.launchpad.net/apt-fast/stable/ubuntu bionic/main amd64 apt-fast all 1.9.10-1~ubuntu18.04.1 [35.4 kB]
42% [2 aria2 526 kB/1,236 kB 43%] [3 apt-fast 8,370 B/35.4 kB 24%]                     
Fetched 1,309 kB in 2s (869 kB/s)                                 
Preconfiguring packages ...
Selecting previously unselected package libc-ares2:amd64.
(Reading database ... 136645 files and directories currently installed.)
....中间省略
Processing triggers for libc-bin (2.27-3ubuntu1) ...

中间提示选择命令时,如果系统有apt命令就选择apt,没有选择apt-get

图片

线程设为16

图片

然后选择YES

图片

这样神器就安装完成了,以后需要使用apt或apt-get命令时,直接将apt/apt-get替换成apt-fast即可,比如要安装openssh-server软件,可输入如下命令进行安装:

linux@ubuntu:~$ sudo apt-fast  install  openssh-server 


01/16 07:33:52 [NOTICE] Downloading 4 item(s)

01/16 07:33:53 [NOTICE] Verification finished successfully. file=/var/cache/apt/apt-fast/ssh-import-id_5.7-0ubuntu1.1_all.deb

01/16 07:33:53 [NOTICE] Download complete: /var/cache/apt/apt-fast/ssh-import-id_5.7-0ubuntu1.1_all.deb

01/16 07:33:53 [NOTICE] Verification finished successfully. file=/var/cache/apt/apt-fast/openssh-server_1%3a7.6p1-4ubuntu0.4_amd64.deb

01/16 07:33:53 [NOTICE] Download complete: /var/cache/apt/apt-fast/openssh-server_1%3a7.6p1-4ubuntu0.4_amd64.deb

01/16 07:33:53 [NOTICE] Verification finished successfully. file=/var/cache/apt/apt-fast/ncurses-term_6.1-1ubuntu1.18.04_all.deb

01/16 07:33:53 [NOTICE] Download complete: /var/cache/apt/apt-fast/ncurses-term_6.1-1ubuntu1.18.04_all.deb

01/16 07:33:53 [NOTICE] Verification finished successfully. file=/var/cache/apt/apt-fast/openssh-sftp-server_1%3a7.6p1-4ubuntu0.4_amd64.deb

01/16 07:33:53 [NOTICE] Download complete: /var/cache/apt/apt-fast/openssh-sftp-server_1%3a7.6p1-4ubuntu0.4_amd64.deb

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
54e7a0|OK  |    10MiB/s|/var/cache/apt/apt-fast/ssh-import-id_5.7-0ubuntu1.1_all.deb
a0fd11|OK  |   2.1MiB/s|/var/cache/apt/apt-fast/openssh-server_1%3a7.6p1-4ubuntu0.4_amd64.deb
e80297|OK  |   2.5MiB/s|/var/cache/apt/apt-fast/ncurses-term_6.1-1ubuntu1.18.04_all.deb
18d3c5|OK  |   136KiB/s|/var/cache/apt/apt-fast/openssh-sftp-server_1%3a7.6p1-4ubuntu0.4_amd64.deb

Status Legend:
(OK):download completed.
Reading package lists... Done
....中间省略
Processing triggers for systemd (237-3ubuntu10.33) ...
linux@ubuntu:~$ 

树莓派上的安装方法

首先下载"apt-fast-master.zip"软件包(PS:可公众号上直接回复"apt神器"获取软件包
然后解压软件包,并将apt-fast命令拷贝到/usr/local/bin目录下,将apt-fast.conf配置文件拷贝到/etc目录下,如下:

pi@raspberrypi:~ $ unzip apt-fast-master.zip 
Archive:  apt-fast-master.zip
5f853c97ddc3704898b47e2e5af9714d68e2ff69
   creating: apt-fast-master/
  inflating: apt-fast-master/LICENSE  
  inflating: apt-fast-master/Makefile  
  inflating: apt-fast-master/README.md  
  inflating: apt-fast-master/apt-fast  
  inflating: apt-fast-master/apt-fast.conf  
   creating: apt-fast-master/completions/
   creating: apt-fast-master/completions/bash/
  inflating: apt-fast-master/completions/bash/apt-fast  
   creating: apt-fast-master/completions/fish/
  inflating: apt-fast-master/completions/fish/apt-fast.fish  
   creating: apt-fast-master/completions/zsh/
  inflating: apt-fast-master/completions/zsh/_apt-fast  
   creating: apt-fast-master/man/
  inflating: apt-fast-master/man/apt-fast.8  
  inflating: apt-fast-master/man/apt-fast.conf.5  
  inflating: apt-fast-master/quick-install.sh  

pi@raspberrypi:~ $ cd apt-fast-master/
pi@raspberrypi:~/apt-fast-master $ sudo cp apt-fast /usr/local/bin/
pi@raspberrypi:~/apt-fast-master $ sudo cp apt-fast.conf  /etc/

然后安装aria2 软件(PS:建议先执行下sudo apt update 或者sudo  apt-get update 

pi@raspberrypi:~/apt-fast-master $ sudo apt install  aria2 -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libaria2-0 libc-ares2
The following NEW packages will be installed:
  aria2 libaria2-0 libc-ares2
0 upgraded, 3 newly installed, 0 to remove and 196 not upgraded.
2 not fully installed or removed.
Need to get 1,350 kB of archives.
After this operation, 5,395 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/raspbian/raspbian buster/main armhf libc-ares2 armhf 1.14.0-1 [80.4 kB]
Get:2 http://mirrors.aliyun.com/raspbian/raspbian buster/main armhf libaria2-0 armhf 1.34.0-4 [908 kB]
Get:3 http://mirrors.aliyun.com/raspbian/raspbian buster/main armhf aria2 armhf 1.34.0-4 [362 kB]
Fetched 1,350 kB in 6s (228 kB/s)

之后就可以用apt-fast愉快的替换apt或者apt命令了,如安装open-sserver软件就可以用

sudo apt-fast  install  openssh-server 

 

更多参考

【树莓派】Linux内核编译

【树莓派】让你的SD卡快速扩容

【树莓派】配置串口登录

【树莓派】系统启用SSH服务

【树莓派】配置无线网络(wifi)

  apt命令常用功能介绍

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值