Ubuntu system is one of the most popular Linux distributions. Here is a method to automatically switch to the fastest source in the command line.
sudo apt install python3-pip python3-setuptools python3-wheel
pip3 install apt-smart
This will install the apt-smart Python script for automatically switching sources. The usage of this script is very simple:
To list the fastest sources:
apt-smart -l
To apply the fastest source:
apt-smart -a