Finding the fastest Debian mirror can significantly improve the speed of package installations and updates. This is where netselect-apt shines, a handy tool for Debian users that automates the process of selecting the quickest server based on network latency and bandwidth. By using this tool, you can ensure that your system updates and installs packages as efficiently as possible.
In this tutorial you will learn:
- How to install and run netselect-apt
- How to use the generated sources list for faster package downloads

| Category | Requirements, Conventions or Software Version Used |
|---|---|
| System | Debian or Debian-based Linux distribution |
| Software | netselect-apt package |
| Other | Internet connection |
| Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Setting Up netselect-apt
Follow these steps to install and utilize netselect-apt for optimizing your Debian system’s package management.
- Installation: Start by installing the netselect-apt package on your system.
# apt update # apt install netselect-apt
This command updates your package lists and installs netselect-apt.
- Running netselect-apt: Execute netselect-apt to find the fastest mirror.
# netselect-apt
This command will analyze and select the fastest mirror based on current network conditions, efficiently scanning for the optimal server that can deliver the quickest download speeds for updates and installations. The result of this selection process is the generation of a
sources.listfile, which will be created in the directory from which the command was executed. This file contains the best mirror URLs determined during the analysis, ready to be used to configure your system for software updates. - Specifying a Debian release: You can specify a particular Debian release to tailor the mirror search.
# netselect-apt -n bullseye
Replace ‘bullseye‘ with your current Debian release for more accurate results. This adjustment is crucial because different releases might be hosted on different mirrors, or some mirrors might be more up-to-date with certain releases than others. For instance, if you are using ‘buster‘ or ‘stretch‘, substituting ‘bullseye‘ with the appropriate release name will help netselect-apt find the most efficient and reliable server for your setup, leading to more precise and satisfactory results.
- Customizing the Mirror Search: To tailor the mirror selection process for your specific needs, including specifying the geographical location of the mirror, the number of mirrors to compare, the system architecture, and the Debian version, use the following command as an example:
# netselect-apt -c us -t 15 -a amd64 -n testing
This command configures netselect-apt to find the fastest mirror located in the United States (
-c us), compares results from 15 different sites (-t 15), targets the amd64 architecture (-a amd64), and searches for the ‘testing‘ release version (-n testing). You can replace ‘us‘ with other country names like ‘australia‘ or ‘slovakia‘ to find mirrors in different regions. Additionally, you can change ‘testing‘ to other Debian versions such as ‘stable‘ or ‘unstable‘ based on your requirements. - Updating your sources.list: Before replacing your existing sources.list, it’s important to back it up. Execute the following commands in the terminal where you ran the netselect-apt command.
# cp /etc/apt/sources.list /etc/apt/sources.list.backup # cp sources.list /etc/apt/sources.list # apt-get update
This first command creates a backup of your original sources.list file as ‘sources.list.backup’. The second command replaces your existing sources.list with the new one generated by netselect-apt located in the current working directory. The final command updates your package lists to reflect the new mirror, potentially speeding up future package installations and updates.
Conclusion
By following the steps outlined in this tutorial, you can optimize your Debian system for faster and more reliable package downloads using netselect-apt. This tool simplifies the process of finding a fast, reliable server, ensuring that your system remains up to date and secure with minimal download times.