> ## Content Index
> Fetch the complete content index at: https://www.binarysludge.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Switch to Debian testing repository using the fastest mirror
- URL: https://www.binarysludge.com/2016/06/15/switch-to-debian-testing-repository-using-the-fastest-mirror/
- Published: 2016-06-15T15:10:00.000Z
- Updated: 2016-06-16T11:15:33.000Z
- Author: Andrew Martin
- Tags: linux, System Administration, debian, #Import 2026-10-22 12:56

**TL;DR** [here's a script](https://gist.github.com/sublimino/7fdcfac9bb3d8c582ab1ee8a618e86b6?ref=binarysludge.com) to pull all the below together (fastest mirror tested using [netselect-apt](http://manpages.org/netselect-apt?ref=binarysludge.com)):

---

To fully migrate to Debian's `testing`/`unstable` repos (`testing` is preferred, `unstable` is present in case of dependency errors) first backup `/etc/apt/sources.list`:

```
cp -a /etc/apt/sources.list ~/sources.list.bak

```

Then check the state of the `sources.list` (as there may be references to `stable` in `sources.list.d/` \- we'll repeat this after migrating to `testing`).

```
grep 'debian.org.*stable' /etc/apt/sources.list /etc/apt/sources.list.d/* 

```

Add the non-free repos

```
sudo sed 's/main$/main non-free contrib/g' -i /etc/apt/sources.list

```

Rename entries for `stable` and `jessie` to `testing`:

```
sed -E 's# (stable|jessie)# testing#ig' -i /etc/apt/sources.list

```

Set `apt`'s default release

```
sudo sed 's#APT::Default-Release "stable";#APT::Default-Release "testing";#g' \
    -i /etc/apt/apt.conf.d/99defaultrelease

```

The install should now be on `testing`. Verify by `grep`ping sources for `stable` (there shouldn't be any results):

```
grep 'debian.org.*stable' /etc/apt/sources.list /etc/apt/sources.list.d/* 

```

Update the repositories:

```
sudo apt update

```

Install `apt-listbugs` and `apt-listchanges`:

```
apt install apt-listbugs apt-listchanges 

```

Verify the installation channel by repeating the install, but specifying the `-t testing` flag - the packages should report that they are already the latest:

```
apt install apt-listbugs apt-listchanges -t testing

```

Verification of the latest version:

```
# apt install apt-listbugs apt-listchanges -t testing
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-listbugs is already the newest version (<cut>).
apt-listchanges is already the newest version (<cut>).
...

```

Now, `dist-upgrade` to fully migrate to `testing`:

```
sudo apt full-upgrade

```

Be sure to always check the packages that will be removed. Although `testing` is generally stable, occasionally this can erroneously include `xorg`. Removing `xorg` will prevent X windows from booting (fixes available [here](https://www.computersnyou.com/4945/re-install-xorg-xserver-completely-ubuntu/?ref=binarysludge.com) and [here](http://smxi.org/site/install.htm?ref=binarysludge.com)).

You can safely remove files under `/etc/apt/preferences` and subdirectories:

```
sudo rm /etc/apt/preferences /etc/apt/preferences.d/*

```

When the installation is complete, reboot:

```
sudo shutdown -r now

```

---

Further reading:

- [Repositories for Testing/Unstable Users ](https://debian-handbook.info/browse/stable/apt.html?ref=binarysludge.com#idm140485877996080)
- [System Upgrade](https://debian-handbook.info/browse/stable/sect.apt-get.html?ref=binarysludge.com#sect.apt-upgrade)