Linux
How To Find Best Ubuntu APT Repository Mirror [2023]
Right after installing your fresh copy of Ubuntu, one of the crucial steps is selecting the fastest APT archive mirror. By default, the installer automatically selects the best Archive mirror relative to your geographical location and ISP at the time of the installation. However, this only happens if your PC or server was connected to the internet. If you do not have internet access during the installation process, the installer selects the Main repository. The main repository happens to be located in the US. If you happen to live outside the US, this repository may not the fastest and might sometimes be slow. In this guide, you will learn how to find best Ubuntu APT repository mirror.
To have the best experience when downloading files and packages, selecting the best mirror is paramount. Let’s check out some of the ways that you can find the best APT repository mirror.
Find Best Ubuntu APT Repository Mirror
There are two ways you can go about this: The graphical way and the command-line way.
The graphical way
This is one of the easiest ways to select the best mirror. To get started, head over to the ‘Software & Updates‘ window. A mirror will already be pre-selected. In my case, I’m using the Kenya mirror since I’m geographically located in Kenya.
To select the best mirror, click on the drop-down button and select ‘Other‘.
Next, click on the ‘Select Best Server‘ option.
Thereafter, your system will perform a series of tests to find the best APT mirror for your geographical location. This takes a few seconds, so just be patient.
After the tests, it will display the best suited APT mirror. In my case, the best mirror is located in Tanzania. Click on ‘Choose Server‘ to start using the mirror.
You will be prompted for authentication to effect the changes. Provide your password and hit ‘ENTER’.
Finally, close the ‘Software & Updates’ window by clicking on the close button.
Finally, click ‘reload‘ on the pop-up that appears for the system to start updating the cache.
Find best APT mirror using the apt-smart command-line tool
Written in Python, apt-smart is a command-line tool that enables you to search for APT mirrors that provide the best download speeds for your geographical location. The apt-smart queries the Ubuntu , Debian and Linux Mint mirror lists and selects the best mirror relative to your country or residence. The tool automatically discovers the mirrors and ranks them by their bandwidth and status ( for instance up-tp-date, 2 hours behind, a week behind etc)
Something worth noting is that the apt-smart tool automatically switches to a different mirror when the current mirror is being updated. Thereafter, new mirrors can be manually or automatically selected by the user.
Install apt-smart on Ubuntu
To install apt-smart, first ensure that you have pip3 installed on your system. Thereafter, use pip3 to install apt-smart by running the command:
1 |
$ pip3 install --user apt-smart |
Next, define the path in the bashrc file as shown
1 |
$ echo "export PATH=\$(python3 -c 'import site; print(site.USER_BASE + \"/bin\")'):\$PATH" >> ~/.bashrc |
And finally activate the changes.
1 |
$ source ~/.bashrc |
Perfect. Now you can start using apt-smart tool.
List the current mirror’s details
To display the details of your current mirror, run:
1 |
$ apt-smart --find-current-mirror |
OR
1 |
$ apt-smart -f |
Find Best Ubuntu APT Mirror
To find the best or most recommended mirror for your system, invoke the command:
1 |
$ apt-smart --find-best-mirror |
OR
1 |
$ apt-smart -b |
List mirrors based on rank
To list all the mirrors based on how well they rank, rank the command:
1 |
$ apt-smart --list-mirrors |
OR
1 |
$ apt-smart -l |
Selecting the best APT mirror
To change to the best mirror, run the command:
1 |
$ apt-smart --change-mirror http://ubuntu.mirror.ac.ke/ubuntu |
OR
1 |
$ apt-smart -C http://ubuntu.mirror.ac.ke/ubuntu |
Instead of manually selecting the mirrors, you can instruct the apt-smart tool to automatically detect the mirror and update the sources list as shown:
1 |
$ apt-smart --auto-change-mirror |
And this wraps up this article. We hope you can now select the best APT mirror for your system.
-
DevOps55 years ago
Saltstack Tutorial for beginners [2023]
-
DevOps55 years ago
How to build a Docker cron job Container easily [2023]
-
Linux55 years ago
mail Command in Linux/Unix with 10+ Examples [2023]
-
DevOps55 years ago
Docker ADD vs COPY vs VOLUME – [2023]
-
DevOps55 years ago
How to setup Pritunl VPN on AWS to Access Servers
-
Linux55 years ago
Grep Command In Unix/Linux with 25+ Examples [2023]
-
Linux55 years ago
How To setup Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04
-
Linux55 years ago
Find command in Unix/Linux with 30+ Examples [2023]