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.


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


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


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


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


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


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


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.


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à!
I have been searching to find an answer not even the Debian site or man pages answer. It has to do with search order of “/etc/apt/sources.list” and “/etc/apt/sources.list.d/”. So far what I have found is within “/etc/apt/sources.list” the order of preference is first entry to last entry, but just one non-Debian source that indicated this search order. Suggestion is to add PPA and unofficial repositories to “/etc/apt/sources.list.d/”. II added Debian arm repository to the “/etc/apt/sources.list.d/” and it cause no end of problems with package dependencies mismatch no matter how I tried to sort out to allow apt or apt-get to resolve. In that instance I downloaded the sources for packages in question and compiled using the dpkg-dev tools with of course a few extra sources that seemed to be needed in newer versions. I am now faced with do I make my own repository on the SD card for these compiled packages and if so is the repository placed in “/etc/apt/sources.list” or “/etc/apt/sources.list.d/” such that will be first considered and used to resolve such that these packages are not revered to older packages that have serious functional (not bug) issues. Then I need to add ObsPy and again which list and at start of of end of list. So challenging to find the information and also correct information. I have spent much time creating custom images for X86 and now Pi that for the basis of multiple systems configuration, I do not want to loose what hard work and time I have put into the efforts to have it mess up and be forced to start over again. I rather not test to find out as the tests I could use may not cover all of the combinations of situations that can arise with complex package and release management (suffice to say my extensive IT career was often dealing with bugs and issues often due to release management many times over on many contracts across multiple environment/technology systems and software engineering roles).
like “itgirls” is officially a term… idk why females had to be offended when we men said things like “it’s not a job for them”. I mean nice we have someone in the team from the other gender, ok, nice. but this term kinda bothered me like… we know… we, as men, know gender doesn’t matter for any job. but don’t make this term as if it is / was divided from men… that is wrong… I did found this Article __very__ useful, Thank you. and have a nice day (or whatever is left of it today)
Hi there!
Thank you for your comment. I agree that the term “IT girl” can be somewhat polarizing and that our field is not one that should be considered from a gendered lens. I used it as a tongue-in-cheek to the famous “IT guy” colloquialism we often use when referring to the IT pro on the payroll. The good news is, women are more and more represented in the field. For instance, where I live women’s representation in Soft Eng is growing steadily (around a quarter of the alumni are women). I’m glad that you found the article useful. Have a great day!