Let's assume that we are using Ubuntu 18.04 LTS (Bionic Beaver).
I know GUI ways to switch currently used APT mirror.
User should open Software & Updates (software-properties-gtk
or software-properties-kde
) and navigate to Ubuntu Software (Kubuntu Software) tab and then select mirror in Download from list:
But how to switch APT mirror from the commandline?
Notes/updates:
- I need a solution without direct editing of
/etc/apt/sources.list
to prevent typos and automate correct mirror selection. - I need to switch mirror with one simple command as equivalent of picking one from Download from list in
software-properties-gtk
(also it is interesting where mirror addresses are saved in the system).
3. I created discussion and poll named "Does Ubuntu need console alternative for software-properties-gtk / software-properties-kde?" on community.ubuntu.com.
List of mirror servers are retrieved by Python library (the
get_server_list
procedure is defined in/usr/lib/python3/dist-packages/aptsources/distro.py
and called from/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py
).The solution is to use tool named
apt-mirror-updater
. It is installable frompip
/pip3
:Functionality:
So it allows to find best mirror and apply it to
/etc/apt/sources.list
:Also it allows to select mirror by URL and apply it to
/etc/apt/sources.list
:and then select mirror by hand:
Some solution (tested on my Ubuntu 18.04.1 LTS): https://github.com/jblakeman/apt-select.git
Install:
or:
Adding script to PATH to run it from everywhere (make it permanent):
Examples usage:
Get the top mirror from the United States to generate a new sources.list::
Choose from the top 3 mirrors, including those last updated a week ago::
Select from 5 US mirrors with the lowest latency to your machine: