Debian is well-known for its stability. However, because of this focus on stability, some packages may not have the latest features or updates as time passes. Debian provides a solution for this through backports and experimental repositories.
Backports are packages from newer versions of Debian that are recompiled to work on older versions. This allows users to get new features without compromising system stability. Experimental repositories contain very new and potentially unstable software that is not yet ready for the main repositories. These repositories give users access to the latest software but with the risk of instability.
Now, we will demonstrate how to use backports and experimental repositories using the command line terminal.
Enable Backports Repository
The first step to installing packages from the backports repository is adding the repository to the sources.list
file. Follow these steps to enable the backports repository on your Debian system:
Open the terminal on your Debian system, then execute the command below to open the sources.list
file with the nano text editor:
sudo nano /etc/apt/sources.list
Append the appropriate lines to the file based on your Debian version. Use the correct codename for your Debian distribution to avoid issues.
Bookworm backports
deb http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware
deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware
Bullseye backports
deb http://deb.debian.org/debian bullseye-backports main contrib non-free
deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
Buster backports
deb http://deb.debian.org/debian buster-backports main contrib non-free
deb-src http://deb.debian.org/debian buster-backports main contrib non-free
Save the configuration file by pressing CTRL+O
, and then exit with CTRL+X
.
Update the repository list by running the following command:
sudo apt update
Alternative Enable Backports
An alternative is adding Debian backports to your sources list; you can use the echo command and the tee command. The tee command reads from standard input and writes to standard output and files. This method will help you avoid using a text editor and do this directly from the command line.
Bookworm, the command would be:
echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list
Bullseye, the command would be:
echo "deb http://deb.debian.org/debian bullseye-backports main contrib non-free" | sudo tee -a /etc/apt/sources.list
Buster, the command would be:
echo "deb http://deb.debian.org/debian buster-backports main non-free" | sudo tee -a /etc/apt/sources.list
Then run an APT update:
sudo apt update
Install Packages from Backports
Using backports on Debian is straightforward; the syntax is similar to installing a standard package, except you’ll add the -t
flag.
Search packages from Debian Backports
Use the following command to search for packages in the backports repository, replacing "package-name"
with the desired package name:
Bookworm example:
sudo apt search "package-name" -t bookworm-backports
Bullseye example:
sudo apt search "package-name" -t bullseye-backports
Buster example:
sudo apt search "package-name" -t buster-backports
Installing or Upgrading Packages from Debian Backports
Use the following command to install or upgrade packages from the backports repository, replacing "package-name"
with the desired package name:
Bookworm example:
sudo apt install "package-name" -t bookworm-backports
Bullseye example:
sudo apt install "package-name" -t bullseye-backports
Buster example:
sudo apt install "package-name" -t buster-backports
Live Example: Installing Cockpit on Debian 11
For example, to install Cockpit on Debian 11 using the backports repository, run the following command:
sudo apt install cockpit -t bullseye-backports
This command will install the newer Cockpit version in the backports repository, providing access to more up-to-date features.
Enabling the Experimental Repository
The experimental repository has the latest software from Debian for those who want the latest updates. But be careful: this repository is best for test systems or developers and system administrators who know the risks and can fix any problems. It is more likely to have compatibility issues and should not be used on live servers or important systems.
Enable Experimental Repository
Re-open the sources.list
configuration file by running the following command:
sudo nano /etc/apt/sources.list
Add the following lines at the end of the file after the lines you previously added for the backports repository:
deb http://deb.debian.org/debian experimental main contrib non-free
deb-src http://deb.debian.org/debian experimental main contrib non-free
Save the configuration file by pressing CTRL+O
, and then exit with CTRL+X
.
Update the repository list by running the following command:
sudo apt update
Now, you can use the -t
flag with the experimental
keyword in your commands to search and install packages from the experimental repository.
Searching for Packages in the Experimental Repository
Use the following command to search for packages in the experimental repository, replacing "package-name"
with the desired package name:
sudo apt search "package-name" -t experimental
Installing Packages from the Experimental Repository
Use the following command to install packages from the experimental repository, replacing "package-name"
with the desired package name:
sudo apt install "package-name" -t experimental
Be careful when using packages from the experimental repository, especially on live servers or systems with important services. The experimental repository is not recommended for general use because of the higher risk of compatibility issues and problems.
Conclusion
By following this guide, you’ve learned how to enable Debian backports and experimental repositories on your Debian system. This lets you install newer packages and enjoy the latest features and bug fixes while keeping your system stable. I recommend regularly checking for updates from these repositories to keep your system current.
Sorry, question (2) should read “how do you UNinstall a package?”
Thank you, this is a very clear guide. I have a couple of questions.
(1) you state “Append the appropriate lines to the file based on your Debian version. Use the correct codename for your Debian distribution to avoid issues.”
For the bookworm backport you mention 2 lines:
deb http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware
deb-src http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware
I am on Linux Mint Debian Edition (LMDE) 6 Faye, which is based on Debian 12 Bookworm, so how do I know which of the 2 lines is the appropriate one?
If, as an example the 1st line is the appropriate one, should I add that line to the file as
deb http://deb.debian.org/lmde bookworm-backports main contrib non-free-firmware
(2) how do you install a package?
Hi Ernesto,
Thank you for your thoughtful questions. Let me clarify:
Since LMDE 6 (Linux Mint Debian Edition) is based on Debian 12 Bookworm, you should use the following line to enable the Bookworm backports repository:
deb http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware
The second line (
deb-src
) is used for downloading and compiling source code. If you don’t need source code, stick with the first line.To add this line via the terminal, use:
echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free-firmware" | sudo tee -a /etc/apt/sources.list
To install a package from the backports repository, use the
-t
flag with the repository name.For example, to install a package named example-package from Bookworm backports, run:
sudo apt install example-package -t bookworm-backports
To search for packages in the backports repository:
sudo apt search example-package -t bookworm-backports
To uninstall a package, use the
apt remove
command:sudo apt remove example-package
If you want to remove the package along with its configuration files, use:
sudo apt purge example-package
Let me know if you need further clarification or additional assistance! 😊