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

last updated in Categories , , ,

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 or Ubuntu 17.04 desktop system? 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
$ 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
$ 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:
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 xenial/universe amd64 libssh2-1 amd64 1.5.0-2 [70.3 kB]
Get:2 xenial/main amd64 apt-fast all 1.8.3~137+git7b72bb7-0ubuntu1~ppa3~xenial1 [34.4 kB]
Get:3 xenial/main amd64 libc-ares2 amd64 1.10.0-3 [33.9 kB]
Get:4 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

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.

A note about Ubuntu Linux version 17.04 “zesty” and Debian Linux

Type the following command to install the same on Ubuntu 17.04 or Debian Linux based system:
$ cd /tmp
$ wget
$ more vokNn
$ sudo bash vokNn

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


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


7 comment

  1. 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.

  2. This doesn’t work.

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

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

Leave a Comment