≡ Menu

How to use multiple connections to speed up apt-get on Ubuntu Linux 16.04 LTS server with apt-fast

How do I speed up my apt-get or apt command to download packages from multiple repos on a Ubuntu Linux 16.04 or 14.04 LTS server? How do I use apt-fast command on a Debian Linux server?

You need to use apt-fast shell script wrapper. It should speed up apt-get command/apt command and aptitude command by downloading packages with multiple connections per package. All packages are downloaded simultaneously in parallel. It uses aria2c as default download accelerator.

Install software-properties-common for PPA

You need to install the following package in order to use PPA on Ubuntu server:
$ sudo apt-get install software-properties-common

Install apt-fast tool

Type the following command on Ubuntu Linux 14.04 and later versions:
$ sudo add-apt-repository ppa:saiarcot895/myppa
Sample outputs:

Fig.01: installing repository

Fig.01: installing repository


Update your repo:
$ sudo apt-get update
OR
$ sudo apt update
Sample outputs:
Fig.02: refreshing repository

Fig.02: refreshing repository


Install apt-fast shell wrapper:
$ sudo apt-get -y install apt-fast
OR
$ sudo apt -y install apt-fast
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  aria2 libc-ares2 libssh2-1
Suggested packages:
  aptitude
The following NEW packages will be installed:
  apt-fast aria2 libc-ares2 libssh2-1
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,282 kB of archives.
After this operation, 4,786 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://01.archive.ubuntu.com/ubuntu xenial/universe amd64 libssh2-1 amd64 1.5.0-2 [70.3 kB]
Get:2 http://ppa.launchpad.net/saiarcot895/myppa/ubuntu xenial/main amd64 apt-fast all 1.8.3~137+git7b72bb7-0ubuntu1~ppa3~xenial1 [34.4 kB]
Get:3 http://01.archive.ubuntu.com/ubuntu xenial/main amd64 libc-ares2 amd64 1.10.0-3 [33.9 kB]
Get:4 http://01.archive.ubuntu.com/ubuntu xenial/universe amd64 aria2 amd64 1.19.0-1build1 [1,143 kB]
54% [4 aria2 486 kB/1,143 kB 42%]                                    20.4 kB/s 32s

Configure apt-fast

You will be prompted as follows (a value between 5 and 16 must be entered):

Fig.03: Set maximum number of connections

Fig.03: Set maximum number of connections


And:
Fig.04: Yes suppress apt-fast download confirmation

Fig.04: Yes suppress apt-fast download confirmation


You can edit settings directly too:
$ sudo vi /etc/apt-fast.conf

Please note that this tool is not for slow network connections; it is for fast network connections. If you have a slow connection to the Internet, you are not going to benefit by this tool.

How do I use apt-fast command?

The syntax is:
apt-fast command
apt-fast [options] command

To retrieve new lists of packages using apt-fast

sudo apt-fast update

To perform an upgrade using apt-fast

sudo apt-fast upgrade
To perform distribution upgrade (release or force kernel upgrade), enter:
$ sudo apt-fast dist-upgrade

To install new packages

The syntax is:
sudo apt-fast install pkg
For example, install nginx package, enter:
$ sudo apt-fast install nginx
Sample outputs:

Fig.05: Install new packages

Fig.05: Install new packages

To remove packages

$ sudo apt-fast remove pkg
$ sudo apt-fast remove nginx

To remove packages and its config files too

$ sudo apt-fast purge pkg
$ sudo apt-fast purge nginx

To remove automatically all unused packages, enter:
$ sudo apt-fast autoremove

To Download source archives

$ sudo apt-fast source pkgNameHere

To erase downloaded archive files

$ sudo apt-fast clean
To erase old downloaded archive files
$ sudo apt-fast autoclean

To verify that there are no broken dependencies

$ sudo apt-fast check

To download the binary package into the current directory

$ sudo apt-fast download pkgNameHere
$ sudo apt-fast download nginx

Sample outputs:

[#7bee0c 0B/0B CN:1 DL:0B]                                                                          
07/26 15:35:42 [NOTICE] Verification finished successfully. file=/home/vivek/nginx_1.10.0-0ubuntu0.16.04.2_all.deb

07/26 15:35:42 [NOTICE] Download complete: /home/vivek/nginx_1.10.0-0ubuntu0.16.04.2_all.deb

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
7bee0c|OK  |        n/a|/home/vivek/nginx_1.10.0-0ubuntu0.16.04.2_all.deb

Status Legend:
(OK):download completed.

To download and display the changelog for the given package

$ sudo apt-fast changelog pkgNameHere
$ sudo apt-fast changelog nginx

References
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 7 comments… add one }
  • Andy F. July 26, 2016, 11:19 am

    Anyone test this with dsh?

  • dave taht July 26, 2016, 8:06 pm

    While this is a good way to get a bit more performance, it is also a way to mess up your link for yourself and others, if you have “bufferbloat”. There are compelling congestion control related reasons as to why we limit the number of simultaneous open full rate tcp flows to bare minimums. In the original http 1.1 standard, it was 2 flows. In the case of doing apt-get system updates, which are a task that is usually not time critical, I imagine that more than 4 is actually counter productive.

  • faria July 26, 2016, 8:36 pm

    This doesn’t work.

    A normal server reject more than 1 request from the same IP. So this is useless and doesn’t work

  • yuanli July 26, 2016, 11:43 pm

    Thanks for the tip.
    BTW, the syntax for installing new packages should be
    “sudo apt-fast install pkg”

  • Denis Franco de Oliveira March 9, 2017, 2:32 am

    Remember you can disable the annoying “[NOTICE]” lines by putting “log-level=warn” at “~/.aria2/input.conf”

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , ,