How to enable Debian 12 Backports repository

See all Debian/Ubuntu Linux related FAQ
The Debian Linux 12 backports repository offers updated versions of software packages for Debian Stable releases. These packages are sourced from Testing (and sometimes Unstable) branches of Debian, and then optimized and recompiled to function on the current Stable release, such as Bookworm. Let us see how to install and use Debian Linux 12 “Bookworm” Backports repository.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category Package Manager
OS compatibility Debian Linux
Est. reading time 3 minutes

How to enable and use the Debian 12 Backports repository

  1. You need to create a new repo file in the /etc/apt/sources.list.d/ directory using a text editor:
  2. sudo vim /etc/apt/sources.list.d/debian-12-backports.list
  3. Append the following config line:
  4. deb bookworm-backports main
  5. Save and close the file. Update package repo and list, type:
  6. sudo apt update && sudo apt upgrade
    How to enable Debian 12 Backports repository commands

    Enable the repository. Update APT package list to install backports packages {click to enlarge}

  7. To install backported package, type apt command:
  8. sudo apt install -t bookworm-backports {pkg_name}
If you need contrib and firemware backported packages update the /etc/apt/sources.list.d/debian-12-backports.list as follows:
deb bookworm-backports main contrib non-free-firmware
Then update the repo:
$ sudo apt update && sudo apt upgrade

How do I search packages in Debian 12 Backports repository?

You can use the apt search command as follows if you know package name. For example:
$ apt search package-name
# say pkg name is 'xdiskusage', then: #
$ apt search xdiskusage


Sorting... Done
Full Text Search... Done
xdiskusage/stable-backports 1.60-4~bpo12+1 amd64
  Displays a graphic of your disk usage with du

You can also use the apt-cache command as follows when you know package names:
$ apt-cache search -t bookworm-backports {pkg_name_here}
$ apt-cache search -t bookworm-backports xdiskusage
$ apt-cache search -t bookworm-backports python3-omemo-dr

Listing all available packages in Debian Linux 12 backports

Of course, you can search and list all packages using combination of the apt command and grep command/egrep command as follows:
$ apt search . | grep -E 'bpo12|stable-backports'
$ apt search . | grep -E 'bpo12|stable-backports' | less

You can easily count all packages using the wc -l command and then print it using the printf command or echo command:
$ apt search . | grep -E 'bpo12|stable-backports' > /tmp/list.txt
$ wc -l /tmp/list.txt
$ echo "Total packages in backport repo : $(apt search . | grep -E 'bpo12|stable-backports' | wc -l)"


Total packages in backport repo : 322

Searching for a specific package among all Debian Linux 12 backports

Again, the syntax is same but you need to use the grep command. Let us search for all python packages from backports:
$ apt search . | grep -E 'bpo12|stable-backports' | grep -i python
Outputs (note bpo12 means backpors 12):

libqgispython3.28.12/stable-backports 3.28.12+dfsg-1~bpo12+1 amd64
libqgispython3.28.13/stable-backports 3.28.13+dfsg-1~bpo12+1 amd64
libqgispython3.28.14/stable-backports 3.28.14+dfsg-1~bpo12+1 amd64
libqgispython3.28.15/stable-backports 3.28.15+dfsg-1~bpo12+1 amd64
librust-pythonize-dev/stable-backports 0.19.0-1~bpo12+1 amd64
python-igraph-doc/stable-backports 0.11.4+ds-1~bpo12+1 all
python-pytest-trio-doc/stable-backports 0.8.0-2~bpo12+1 all
python3-baler/stable-backports 1.3.0-1~bpo12+1 amd64
python3-dar/stable-backports 2.7.13-1~bpo12+1 amd64
python3-mini-buildd/stable-backports 2.0.15~bpo12+1 all
python3-omemo-dr/stable-backports 1.0.1-2~bpo12+1 amd64
python3-pytest-trio/stable-backports 0.8.0-2~bpo12+1 all
python3-pyzfs/stable-backports 2.2.3-1~bpo12+1 amd64
python3-sabctools/stable-backports 8.1.0-1~bpo12+1 amd64
python3-scriptforge/stable-backports 4:24.2.0-1~bpo12+1 all
python3-sdbus/stable-backports 0.12.0-1~bpo12+1 amd64
python3-sphinx-design/stable-backports 0.5.0-2~bpo12+1 all
python3-varlink/stable-backports 31.0.0-2~bpo12+1 all

So what does the python3-omemo-dr package do? Let us find out:
$ apt info -a python3-omemo-dr

Package: python3-omemo-dr
Version: 1.0.1-2~bpo12+1
Priority: optional
Section: python
Source: omemo-dr
Maintainer: Debian XMPP Maintainers <>
Installed-Size: 343 kB
Depends: python3 (<< 3.12), python3 (>= 3.11~), python3-cryptography, python3-protobuf, python3:any, libc6 (>= 2.14)
Download-Size: 99.2 kB
APT-Sources: bookworm-backports/main amd64 Packages
Description: OMEMO double ratchet for Python
 Initial codebase was forked from python-axolotl, which is a Python 3
 port of libaxolotol-android. The library is defined as a ratcheting
 forward secrecy protocol that works in synchronous and asynchronous
 messaging environments.

Installing packages from backports repo

Simply use any one of the following syntax:
$ sudo apt install <package>/bookworm-backports
$ sudo apt-get install <package>/bookworm-backports
$ sudo apt install -t bookworm-backports <package>
$ sudo apt-get install -t bookworm-backports <package>

Here is how to install python3-omemo-dr:
$ apt install -t bookworm-backports python3-omemo-dr
$ apt-get install -t bookworm-backports python3-omemo-dr

Listing all installed packages from backports repo only

Use any one of the following command
$ dpkg --list | grep bpo12
$ dpkg --list | grep -E 'bpo12|backports'
$ apt list --installed | grep bpo12
$ apt list --installed | grep -E 'bpo12|backports'


ii  python3-omemo-dr            1.0.1-2~bpo12+1        amd64        OMEMO double ratchet for Python

Deleting packages installed from backports repo

Use the following syntax to delete the package:
$ sudo apt remove python3-omemo-dr
## OR ##
$ sudo apt-get remove python3-omemo-dr

Want to get rid of config files too?
$ sudo apt --purge remove python3-omemo-dr
## OR ##
$ sudo apt-get --purge remove python3-omemo-dr

You can use the df command or du command to verify used Linux disk space when you add or remove packages:
$ df -H

Installing, listing, and removing packages from Debian 12 backports commands demo

Installing, listing, and removing packages from Debian 12 backports commands demo {click to enlarge}

Wrapping up

Now you know how to enable, install and search Debian 12 Backports packages. Please noete that Backports aims to provide access to new software features and updates while maintaining Debian’s stable and well-tested base. The package source is primarily taken from Debian Testing, with the rare exception of coming from Unstable for security updates. Backported packages are precisely adjusted to work with the libraries and dependencies available in Debian Stable to ensure compatibility. You can selectively install individual backported packages or configure your system to prioritize Backports for specific software. For more info see the Debian wiki page here and read the following manual pages using the help command or man command:
$ man apt
$ man apt-get
$ man apt-cache

See also

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

1 comment… add one
  • Mr Daniel Smith May 11, 2024 @ 21:12

    Looks great just about to try it on my raspberrypi

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.