⚡ Speed Up apt and dnf by Auto-Selecting the Fastest Mirrors

Tired of slow package updates on your Linux system? Learn how to automatically find and use the fastest mirrors for apt and dnf package managers, making your system faster and more efficient.

Package updates dragging? On Linux, your mirror source makes all the difference in update/download speeds. Here's how to automatically select the fastest mirrors for apt (Debian/Ubuntu) and dnf (Fedora/RHEL/CentOS) — no manual guessing.


🧠 TL;DR

  • Use netselect or apt-fast (Debian/Ubuntu) to pick faster apt mirrors.
  • Use dnf config-manager or fastestmirror=true (Fedora/RHEL) to enable faster mirrors.
  • Significant speed boosts for downloads and updates.
  • Commands included for real-time mirror tests.

🧪 For Debian/Ubuntu Systems (apt)

🔹 Step 1: Install netselect-apt (or apt-fast for advanced users)

sudo apt update
sudo apt install netselect-apt -y
netselect-apt benchmarks mirrors for your release and generates a new sources.list.

🔹 Step 2: Run It for Your Distribution

sudo netselect-apt stable
Replace stable with bookworm, bullseye, buster, etc., as appropriate.

It creates a new /etc/apt/sources.list. Back yours up and use the new one:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp sources.list /etc/apt/sources.list

✅ Optional: Use apt-fast for Parallel Downloads

sudo add-apt-repository ppa:apt-fast/stable -y
sudo apt update
sudo apt install apt-fast -y
apt-fast uses aria2 to download packages in parallel = huge speed gains!

🔧 For Fedora, RHEL, or CentOS Systems (dnf)

🔹 Step 1: Enable Fastest Mirror Plugin

Edit the DNF config using vim:

sudo vim /etc/dnf/dnf.conf

Add or update these lines:

fastestmirror=True
max_parallel_downloads=5
fastestmirror=True: Automatically ranks fastest mirrors
max_parallel_downloads: Boosts simultaneous downloads (set to 10 if on good bandwidth)

🔹 Step 2: Clean Cache and Test

sudo dnf clean all
sudo dnf makecache

Try a package install and see the difference:

sudo dnf install htop

🧠 Why This Matters

Default mirror selection is rarely optimized for speed. By benchmarking and enabling these tweaks:

  • You reduce wait time for updates/upgrades
  • Install packages faster (especially big ones like Chromium or kernel headers)
  • Improve automation speed for scripts and CI/CD tasks

🧼 Restore Defaults (if needed)

If something breaks or feels off, just restore your original backup:

sudo mv /etc/apt/sources.list.bak /etc/apt/sources.list

Or turn off fastest mirror in DNF:

sudo vim /etc/dnf/dnf.conf
# Set fastestmirror=False

✅ Summary

Distro Method
Debian/Ubuntu netselect-apt or apt-fast
Fedora/RHEL fastestmirror=True in DNF

This quick tweak = faster updates + a smoother Linux experience.


🧵 Filed under: #linux #apt #dnf #performance #mirror-speed