Upgrade Debian 11 Bullseye to Debian 12 Bookworm From Command Line

Debian 12, codenamed Bookworm, was released on June 10, 2023. This tutorial is going to show you how to upgrade Debian 11 to Debian 12 from the command line. You can follow this tutorial on a Debian 11 desktop, or Debian 11 server. As with every Debian release, Debian 12 will be supported for 5 years. The codename “Bookworm” is named after the green toy worm in the Toy Story movie.

Recommendations Before the Upgrade

If you installed the proprietary Nvidia driver on Debian 11 desktop, I recommend removing it before the upgrade because the Nvidia driver caused package conflict when I attempted to upgrade Debian bullseye to bookworm.

sudo apt remove *nvidia*

Before doing the upgrade, you can make a backup of your computer using Clonezilla. If the upgrade fails, you can easily restore your OS. Everything on your OS including software and files will be intact.

If you are trying to upgrade a Debian VPS (Virtual Private Server), you can use your hosting provider’s snapshot functionality to create a snapshot of your server.

If you are using a laptop, please connect your power source.

Keep Your SSH Session Alive

If you use SSH to log into your Debian server, it’s a good idea to keep your OpenSSH session alive by using the screen utility. Install screen on the Debian 11 server:

sudo apt install screen

Then start screen:

screen

Upon the first launch, you will see an introduction text, simply press Enter to end. Then you will be able to run commands as usual.

It’s also recommended to add the following line at the bottom of the /etc/ssh/sshd_config file on your server to keep your SSH session alive.

ClientAliveInterval 60

Save and close the file. Then restart SSH daemon.

sudo systemctl restart ssh

Upgrade Debian 11 Bookworm to Debian 12 Bookworm Using Command Line

You can use the command line to upgrade Debian desktop or a headless server. To upgrade to Debian 12, switch to root user with the following command. You will need to enter the root user’s password.

su -

If you have a sudo user, you can also switch to root by using the following command. You will need to enter the sudo user’s password.

sudo su -

Then update existing software using the following two commands.

apt update

apt upgrade

If a new kernel is installed when running the above command, then you need to reboot the system in order to continue the upgrade process. To reboot Debian, run the following command. (Remember to switch to root user again after the reboot.)

shutdown -r now

Next, we need to edit the sources.list file with a command-line text editor such as Nano.

nano /etc/apt/sources.list

Change all instances of bullseye to bookworm. If you don’t like changing it one by one, then you can exit out of Nano text editor (Press Ctrl+X) and run the following command for batch replacement.

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

Debian 12 moved non-free firmware to its own component in the archive. If you have non-free firmware installed it is recommended to add non-free-firmware to your APT sources-list.

sudo add-apt-repository non-free-firmware

Then we need to disable third-party repositories with the following command, which will add a # character at the beginning of line for every .list file in /etc/apt/sources.list.d/ directory.

sed -i 's/^/#/' /etc/apt/sources.list.d/*.list

Next, update software sources and upgrade software to the latest version available in the bookworm repository. This step is called minimal upgrade.

apt update

apt upgrade

If the apt-listchanges shows up during the upgrade, you can press the Q key to return to the main screen.

upgrade debian buster to debian bullseye

When upgrading packages, you will be asked if you want to restart services without asking. If you want to manually restart services, choose No. This tutorial selects Yes, because my Debian box doesn’t have a service that needs to be accessed by the public.

upgrade-debian-10-to-debian-11

You will also likely to be asked if you want to install new version of configuration files. I always choose No (Just press Enter) to be on the safe side. (The new configuration file will be saved with the same file name but with the .ucf-dist or .dpkg-dist extension, which you can examine after the upgrade.)

debian buster upgrade Installing new version of config file

Once minimal upgrade is finished, run the following command to begin full upgrade.

apt dist-upgrade

Now you can remove obsolete/unneeded software packages from your Debian system.

apt autoremove

apt clean

Finally, reboot the system.

shutdown -r now

Check your Debian version.

lsb_release -a

You should see the following text.

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm

Congrats! You have successfully upgraded to Debian 12 Bookworm.

Next Step

I hope this tutorial helped you upgrade Debian 11 to Debian 12. You can also attend a Debian release party to celebrate it! As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 30 Average: 4.5]

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here