If you’ve installed Debian stable, then you might have come across situations where you weren’t able to install an application you wanted. That is because Debian stable, by its very nature, is older than its testing and unstable counterparts. In such a case, knowing how to add a specific Debian repository and backports will come in handy.

By providing a higher level of stability and security due to its extensive testing, Debian Buster unfortunately also provides an OS that is outdated when compared to other releases. Unfortunately, that also means that many applications will require the use of backports to install the newer version of their program on Debian stable. 

Alternatively, such software programs might require the addition of a repository to your system before you can install them. Indeed, significant app updates often involve newer technology. As such, the newly updated program will become unsupported or unavailable through the regular Debian stable ports and repos.

Fortunately, it is not because a program isn’t readily available on your version of Debian that you will have to change your OS. By knowing how to add a specific Debian repository or backports to your source files, you can install your app as if you were using the testing (Bullseye) or unstable (Bookworm) release. 

What are Debian backports? And what is a Debian repository?

In brief, backports allow cross-version package compatibility through the use of non-stable package channels. These, in turn, will enable you to fetch specific applications from other releases and to install them on your own Debian stable system. As for repositories, they will allow you to import the particular packages necessary for your app, regardless of your current Debian release. Sometimes, you will have to add repos even if you are using a newer version such as Debian Bullseye. However, it is common to find out that a Debian repository is only necessary if you are using the older, stable Debian release.

A word of caution: as indicated in the ITgirl.tech’s Debian installation guide, avoid creating a “Frankendebian” (see the avoiding common pitfalls section). If you see that you often add a Debian repository, or use backports to install the majority of your applications, consider upgrading your system to Debian testing or unstable. Note also that the extensive use of backport packages can increase your risk of experiencing bugs or crashes.

A picture showing a representation of Frankenstein, with the word "frankendebian."
Representation of the dreaded Frankendebian. Picture courtesy of debiman (forums.debian.net)

Even more so than with Debian repositories, it is best to use backports with parsimony. Indeed, there is no guarantee that you won’t end up with components of your Debian stable being incompatible with the packages fetched through the backports. As such, it is recommended to limit yourself to a few backported packages and not to rely on backports whenever you want to install a new application. The use of a Debian repository doesn’t require such precautions, but it is still a Linux best practice to limit your usage of them whenever possible.

How to add a Debian repository

The addition of a repository on your Debian OS is straightforward. The only information you will need is the name of the repo required by the app, which you can find within the software’s instructions. Alternatively, the Debian Wiki will often provide the repos of specific apps. 

I’ve seldom had to add particular repos in the past. However, off the top of my head, I remember having had to do this procedure when switching my Ubuntu desktop from GNOME 3 to Cinnamon. That ITgirl.tech article is for a different Linux distribution, but I had hoped to use its procedure in this article. Unfortunately, adding a repository requires different steps on Debian, so be sure to follow the process below. Indeed, even though Ubuntu procedures sometimes work as-is (or with slight changes) on Debian, adding a repo requires Debian-specific instructions.

Let’s say that you want to add Spotify to your Debian Buster operating system. To do so, you will need to fetch the Spotify Debian repository, which you can find here: https://wiki.debian.org/spotify

Note that in this particular case, Spotify requires a signing key. Be sure to add it before fetching the repo.

Open the Terminal, then type the following:

$ echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list

Adding a Debian repository.
Adding a Debian repository. In this example, the Spotify repo.

Voilà! Simple as that. Once done, update your system ($ sudo apt update), then follow the instructions provided by the app’s developers. 

Installing the Spotify app on Debian.
After having updated the OS, and now ready to install the app! Note the switch from 10.0 to 10.1 after the apt update…I hadn’t started my Debian VM in a while. 

Adding backports to your sources.list

To add backports, you have to edit what is called the “sources.list” file. Be sure to have a backup copy of your original sources.list file, just in case. There are many ways of changing its content; I like to use the “nano” editor.

From the Terminal, enter:

su

Enter your password, then

nano /etc/apt/sources.list

Now, using the keyboard arrows, create a new line after the last source (generally, after “deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free”).

Enter the following:

deb http://deb.debian.org/debian buster-backports main

Adding the Buster backports Debian repository.
The sources.list file, now with the buster-backports added.

Once that is done, exit nano (Ctrl+X). Press the “Y” key to confirm that you want to save the changes. Once done, press Enter. You will automatically exit “nano” and revert to the main Terminal window.

After that, type:

apt-get update

You are now ready to install backported packages!

Installing a package from backports

You can usually find specific backport instructions on the website of the app you want to install. However, a good rule of thumb when in doubt is to type:

apt-get -t buster-backports install [NameOfThePackage]

Where [NameOfThePackage] is the name of the application you wish to install. When in doubt, a quick “apt-search” followed by the common name of the app will ensure that you are indeed using the correct package name.

Contrib non-free repositories and the nonfree firmware packages

If you downloaded the standard Debian ISO file, chances are you might stumble upon some hardware compatibility issues. That is especially the case if you own a new computer and opted for the stable Debian release.

If you see that you are running into problems with hardware detection, one of the first steps is to add the “contrib” and “non-free” repositories to your Debian OS. You will find that the non-free packages are part of the unofficial Debian disk images (and are specified as such). However, they aren’t included in the official stock releases, as their use involves proprietary (ie, non-open-source) drivers. 

If you own a computer with recent hardware, some of your machine’s components might require such closed-source packages to function correctly. In such an instance, manually adding the “contrib” and “non-free” repositories to your sources.list is necessary. Indeed, to fetch the “non-free” drivers, you first require access to them through these dedicated repositories.

To add repositories, you have to edit the “sources.list” file, just as with backports. Once again, be sure to have a backup copy of your sources.list file. To change its content from the command line, we will use the “nano” editor.

From the Terminal, enter:

su

Enter your password, then

nano /etc/apt/sources.list

Using the Terminal to edit the sources.list file on Debian.

After entering your password, you should see something like this:

The edited sources.list file, before adding contrib and non-free.
The sources.list file, after having added the Buster backports but before the addition of the contrib and non-free repos.

Now, using the keyboard arrows, go to the end of each of the following lines and add the “contrib” and “non-free” repositories.

deb http://security.debian.org/debian-security buster/updates main

becomes

deb http://security.debian.org/debian-security buster/updates main contrib non-free

deb-src http://security.debian.org/debian-security buster/updates main

becomes

deb-src http://security.debian.org/debian-security buster/updates main contrib non-free

deb http://deb.debian.org/debian/ buster-updates main

becomes

deb http://deb.debian.org/debian/ buster-updates main contrib non-free

and

deb-src http://deb.debian.org/debian/ buster-updates main

becomes

deb-src http://deb.debian.org/debian/ buster-updates main contrib non-free

The sources.list file, now with the contrib and non-free Debian repos.
The sources.list file, now with the contrib non-free repos.

Once that is done, exit nano (Ctrl+X). Press the “Y” key to save the changes. After that, press Enter. You will automatically exit “nano” and revert to the main Terminal window.

A screenshot of the Debian terminal.

Once in the Terminal, type:

apt-get update

You are now ready to install the non-free packages!

To do so, execute the following command:

sudo apt-get install firmware-linux-nonfree

Voilà!

© 2019, ITgirl.tech. All rights reserved.

Larryssa
Owner and content creator behind ITgirl.tech. Geeky girl and blogger based in Montreal, Canada. Chocolate and nature lover (in that order). View all posts by Larryssa →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!
Don`t copy text!