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.