How To Find And Connect To Fastest Mirror In Linux From Terminal

In this post we will discuss that how to find the fastest repo mirror server in top Linux distros. In graphical way, it is easy in some distros but as we know Linux is basically a command base operating system in which every task is possible by any command. so we must should learn that how to connect to any fastest repo mirror of our Linux distro using terminal. This is must because if you  are not using fastest repo you will get latency and delay to update, download and install any package in your system. So lets start ...

    There are many popular Linux distros available  & it is impossible to demonstrate every individual distros here. So we will choose top  three most popular distros to demonstrate it .

1) Debian base distros

2) RPM base distros 

3) Arch base distros


Debian Base Distros : There are many manual ways either graphical or terminal based that will enable and connect your system to fastest repos but we will discuss the most fast and easy way and there will be less chances of error rather then manually making any changes in system. And most important it is universal method for all Debian base systems.  

For this, you have to download & install the package called  Apt-Smart . An Apt smart is python base utility which will automatically manage and handle the fastest package repo server for APT Package Manager. And it is officially supports Debian/Ubuntu/Mint Linux distros.

Installation : 

1) First confirm the system is up to date with sudo apt-get update

 

2) Once confirmed run below command to install the python and supported packages as the utility is written in python.

sudo apt install python-pip python-setuptools python-wheel -y


3) Now install the main package apt-smart.

pip install --user apt-smart

Note : If you want to install this package for a user's home directory use --user flag.  This will gives you a warning message about to export the local installation path to the $PATH variable.So you have to export the it ( see step 4) . Else you can skip the --user option.

 

4) If --user flag has been chosen  then export the path to $PATH variable with below commands.

echo "export PATH=\$(python -c 'import site; print(site.USER_BASE + \"/bin\")'):\$PATH" >> ~/.bashrc


Then run source ~/.bashrc command.

Now as package has been installed successfully you can run command that will help you to check and edit the mirror repo of system. some important commands are below.

1) Find Current Configured Mirror :

apt-smart --find-current-mirror 

or

apt-smart -f


 2) Find the best mirror for your system and rank them in a list.

apt-smart --find-best-mirror

or

apt-smart -b


  Output Example :


3) List all available (ranked) mirrors on the terminal in a human readable format.

apt-smart --list-mirrors or apt-smart -l


Output Example :


4) Once you find the fastest mirror for your system just update the source.list with below command.

apt-smart --change-mirror=Mirror_URL

 


or

apt-smart -c Mirror_URL


Output Example :


Arch Base Distro : In arch base distro it is very simple and you don't need to install any third party application to connect to fastest mirror. just type below command from your command terminal and that it.

sudo pacman-mirrors --fasttrack && sudo pacman -Syyu


RPM Base Distro : In Redhat/CentOS or any other RPM base distro there is a plugin file which is responsible for connecting your system to your nearest/own country's mirror. To enable this option follow below steps.

For YUM Package Manager:

1) open the file /etc/yum/pluginconf.d/fastestmirror.conf with any text editor (vim or nano etc) .

2) Find option enable = 0 and change the value 0 to 1.

3) Now save the file and exit.

4) Now run command : sudo yum clean all

5) Now run command : sudo yum update

For DNF Package Manager

1) Open file /etc/dnf/dnf.conf with any text editor

2) Find and set below options as true.

fastestmirror=true

deltarpm=true

Where fastestmirror option will connect your system to your nearest mirror and deltarpm will update the packages in Rsync mode. That means only changes to the application will be downloaded. This will reduce the data download size and time as well. 

If you have some suggestion , please comment below to improve this post.

Share This Post On Your Social Media Platform 


Post a Comment

0 Comments