How to Upgrade Debian 11 to Debian 12 (Bookworm) via CLI

Debian 12, code name Bookworm, has been released on June 10th, 2023. It ships with a myriad of new features and improvements over Debian 11.

The latest release of Debian bundles over 11089 new packages, coming to a total of over 64419 packages. Over 67% of the packages in Debian ( this is about 43254 packages)  have been updated, and a further 10% ( about  6,296 packages) that were in Bullseye have been removed and marked as obsolete.

In this post, we look at how to upgrade Debian 11 to Debian 12 via cli step by step. But before we do so, let’s check out some of the key highlights of Debian 12:

What’s new in Debian 12 ?

Here are some of the key highlights of Debian 12:

1.    Linux Kernel 6.1

Debian 12 is powered by Linux kernel 6.1 which is an LTS version that includes numerous enhancements such as improved support for AMD CPUs, experimental support for Rust, and ARM SoC support among many others.

2.    Updated Installer

A new installer is included with Debian 12. It has received several enhancements and other features.

3.    New Wallpaper

As with any other Linux distribution release, Debian 12 includes a new and artistic wallpaper known as ‘Emerald’. It’s quite elegant and polished just like the emerald gemstone from which its name is derived.

4.    Support for Pipewire

Debian 12 provides support for Pipewire out-of-the-box which replaces PulseAudio as the default audio and service.

5.    Newer Software Versions

The latest release of Debian provides the latest software releases which include:

  • MariaDB 10.11
  • PHP 8.2
  • Python 3.11.2
  • Nginx 1.22
  • OpenJDK 17
  • LibreOffice 7.4
  • GNOME 43
  • Perl 5.36
  • Vim 9.0
  • Samba 4.17

And many more.  Those are just a few highlights of what to expect in Debian 12. Check out the release notes for more information on what to expect.

Important: Before doing any upgrade activity, take the backup of your system either using timeshift or rsnapshot utility.

Let’s now see how to upgrade Debian 11 to Debian 12.

Step 1: Update the Local Package Index

To get started, it’s a good idea to refresh the package lists on your system as follows:

$ sudo apt update

Apt-Update-Lsb-Release-Before-Upgrade

Step 2: Install All Available Updates

Run the following apt commands one after the another to install all the available updates,

$ sudo apt upgrade
$ sudo apt full-upgrade
$ sudo apt --purge autoremove

Sudo-Apt-Upgrade-Debian-Cli

Post installing the updates, reboot the system,

$ sudo reboot

Note: Any package which is marked in hold status may cause issue while upgrading so it is recommended to unhold such package before proceeding upgrade.

$ sudo apt-mark showhold | more
$ sudo apt-mark unhold <pkg-name>

Step 3: Update the sources.list file

Since the mission is to upgrade from Debian 11 ( Bullseye) to Debian 12 ( Bookworm) you need to update the /etc/apt/sources.list file by substituting every instance of bullseye with bookworm.

Before making the changes, take the backup of debian 11 sources.list file using beneath cp command,

$ sudo cp -v /etc/apt/sources.list /opt/sources.list-bakup-debian11

Now run sed command to replace every instance of bullseye with bookworm in sources.list file.

$ sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list

Once again, update the package lists to apply the changes made to the package lists.

$ sudo apt update

Replace-Bullseye-with-bookworm-sources-list-deban

Step 4: Upgrade to Debian 12

Now upgrade the system by running the following command:

$ sudo apt full-upgrade

Debian-Apt-Full-Upgrade-Cli-Command

We will be prompted the following screen, press ‘q’ to proceed further.

Pres-q-to-Proceed-further-Debian-Upgrade

When prompted, Choose “Yes” and press ENTER to proceed. You will most likely run into a few prompts. For example, you might be asked whether to restart services. Choose any option that you deem fit by pressing ENTER.

Restart-Services-During-Debian-Upgrade

You will also get prompted to select the version of sshd_config file. Here, we have selected to keep the local version installed.

Keep-Local-Verison-SSHD-During-Debian-Upgrade

Similarly, you will get the same message about the GRUB configuration file.

Keep-Local-Grub-Version-During-Debian-Upgrade

Post upgrade, reboot the system once using following reboot command.

$ sudo reboot

Reboot-Post-Debian-Upgrade

Step 5: Verify Debian 12 After Upgrade

Once the system is back online after reboot, open the terminal and run the following command to check Debian version,

$ lsb_release -a

$ cat /etc/os-release

You can also confirm the kernel version as shown.

$ uname -rms

Verify-Debian-Upgrade-Cli-Commands

It is recommended to remove the outdated packages post upgrade using following apt command,

$ sudo apt --purge autoremove

Conclusion

This brings us to the end of this guide. In this tutorial, we showed you how to upgrade to Debian 12 (Bookworm) from Debian 11 (Bulleye).

2 thoughts on “How to Upgrade Debian 11 to Debian 12 (Bookworm) via CLI”

Leave a Comment