How To Speed Up Slow Apt Get Install On Ubuntu

In this article, we’ll cover how to speed up slow apt get install on Ubuntu to speed up the installation process. Continue reading this article to find out!

The Apt-Get Package on Ubuntu

The apt-get is a Ubuntu package management system that permits application updates, upgrades, and installation on Ubuntu machines. However, oftentimes the process gets slow while installing several packages on the system at once. The apt-get package might be slow due to the following reasons:

  • Mirrors issue
  • Name Servers issue
  • Repositories issue
  • Unknown issues

To cope with the slow speed, there are several methods which we’ll discuss in this article. 

How To Speed Up Slow Apt Get Install On Ubuntu

In this section, we’ll look at three methods that we can use to speed up slow apt-get installation on Ubuntu machines. So, let’s get started!

Fix Name Server Issue to Speed Up Slow Apt Get

Name server issue is a common issue that slows down the download process. To speed up slow apt-get, we’ll try to fix the name server issue first. For this step, we’ll first clear the apt-get cache by using the apt-get command as shown below:

sudo apt-get clean

Next, we’ll modify the /etc/resolv.conf file to add to the Google DNS server. 

# nano editor
nano /etc/resolv.conf
# vi editor
vi /etc/resolv.conf

Add the following Google DNS server at the end of the file:

nameserver 8.8.8.8
nameserver 8.8.4.4

The output should look something like this:

speed up slow apt get

Alternatively, we can also add the CloudFare DNS:

nameserver 1.1.1.1
nameserver 1.0.0.1

Press “Ctrl + S” to save and “Ctrl + X” to exit the editor. 

To test the change, update the Ubuntu machine. For this step, use the update command. Specifically, type:

sudo apt-get update && sudo apt upgrade

Transport HTTP to HTTPS to Speed Up Slow Apt Get

The HTTP source is another reason for the slow apt-get install on Ubuntu. If we change the source from HTTP to HTTPS, that’ll speed up the slow apt-get install. For this step, we’ll first install the apt-transport-https package as shown below:

sudo apt install apt-transport-https

After that, we’ll edit etc/apt/sources.list file

nano /etc/apt/sources.list

Change the HTTP in the following line to HTTPS:

deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
deb https://us.archive.ubuntu.com/ubuntu/ focal main restricted

Output:

replace HTTP with HTTPS

Hit “Ctrl + S” and “Ctrl + X” to save and exit the editor. Now to test the speed, run the update and upgrade. Specifically, type:

sudo apt update && sudo apt upgrade

Speed Up Slow Apt Get Using Apt Fast

One of the most common methods is to install an apt-fast package manager for the quick installation of packages and applications. However, we’ll have to set it up first. Follow the steps given below to start using apt-fast instead of apt-get.

Install Apt Fast to Speed Up Slow Apt Get

First, we’ll download the aria2 package, which is a required accelerator. Also, it is not installed by default. Hence, we’ll install it using the apt install command. Specifically, type:

sudo apt install aria2

Output:

Install aria2 package

After that, we’ll execute the bash command given below to install apt-fast:

/bin/bash -c “$(curl -sL https://git.io/vokNn)”

Here’s the breakdown of the command:

  • /bin/bash specifies that the command mentioned should be executed in the bash script.
  • -c represents that the following string should be treated as a command.
  • $(curl -sL https://git.io/vokNn) downloads the URL given as an argument. Also, the double quotes surrounding the command prevent the shell from interpreting any special character.

Here’s the output of the command:

speed up slow apt get

Once done, execute the following commands to install the apt-fast package:

sudo add-apt-repository ppa:apt-fast/stable
sudo apt-get update && sudo apt-get install apt-fast

Alternatively, you can also use the wget command instead of the curl command. For example:

wget https://github.com/ilikenwf/apt-fast/archive/master.zip

Since wget downloads the package, we’ll have to unzip the package, copy the required files to their appropriate directory, reduce the file size, and then install it. Execute the commands given below for this step:

unzip master.zip && cd apt-fast-master
sudo cp apt-fast /usr/bin && sudo cp apt-fast.conf /etc && sudo cp ./man/apt-fast.8 /usr/share/man/man8
sudo gzip /usr/share/man/man8/apt-fast.8 && sudo cp ./man/apt-fast.conf.5 /usr/share/man/man5 && sudo gzip /usr/share/man/man5/apt-fast.conf.5

Configure Apt Fast

Once the operation is complete, we’ll now configure the apt-fast.conf file. For this step, use the nano or vim editor to open the /etc/apt-fast.conf file. For instance, type:

# for nano editor
sudo nano /etc/apt-fast.conf
# for vim editor
sudo vim /etc/apt-fast.conf

Now, uncomment the following lines from the file:

# Debian
MIRRORS=('http://ftp.us.debian.org/debian/,http://carroll.aset.psu.edu/pub/linux/distributions/debian/,http://debian.gtisc.gatech.edu/debian/,http://debian.lcs.mit.edu/debian/,http://mirror.cc.columbia.edu/debian/')

#Ubuntu/Mint
MIRRORS=('http://us.archive.ubuntu.com/ubuntu,http://mirror.cc.columbia.edu/pub/linux/ubuntu/archive/,http://mirror.cc.vt.edu/pub2/ubuntu/,http://mirror.umd.edu/ubuntu/,http://mirrors.mit.edu/ubuntu/')

If the mirrors do not exist in the file, you can add them. Also, make sure to include the default mirror site for both Debian and Ubuntu packages. The default mirrors are specified in the /etc/apt/sources.list in the MIRRORS variable.

Lastly, save the file by pressing “Ctrl + S” and exit the editor by pressing “Ctrl + X”.

Use the Apt Fast to Install a Package

Once the configuration is done, we’ll now try to use apt-fast to download the packages. The syntax of the command looks something like this:

apt-fast [apt-get options and arguments]
apt-fast [aptitude options and arguments]
apt-fast { { install | upgrade | dist-upgrade | build-dep | download | source } [ -y | --yes | --assume-yes | --assume-no ] ... | clean }

Now, we’ll try to install the vlc media player package using apt-fast to speed up slow apt-get. Run the commands given below to speed up the installation process:

sudo apt-fast update && sudo apt-fast upgrade

Output:

Speed up slow apt get
sudo apt-fast install vlc -y

Alternatively, if you want to download the package only, then pass the download parameter with the apt-fast command. Specifically, type:

sudo apt-fast download texlive-full

Since aria2 manages the parallel downloading in apt-fast, we can verify parallel download streams by using the netstat command:

sudo netstat -nap | grep aria2c

The output should look something like this:

grep aria2 package

Learning how to speed up slow apt get is an essential task for every Linux user. Since there might be several issues behind the slow speed, there are many ways to fix this. In this tutorial, we’ve discussed the commonly used methods. Out of these methods, apt-fast is the best tool to speed up slow apt get on Ubuntu.

Learn more about apt cache cleaning. fixing apt command not found error and disabling apt news on Ubuntu.

If you liked this article, please share it. 

Related Posts