How to upgrade Debian
In every two year period, Debian will have no changes. Program and feature versions remain the same during this time. The security fixes are backport (get the new version and then switch to the old version). Sometimes, there are rare exceptions in which a package needs new features. For example, drivers can be upgraded to add support for more hardware. But this case is very rare.
Keeping things constant also has certain advantages, such as making the operating system more reliable. You almost never encountered an error. Everything is almost never broken after updating the package. Without new features means no unwanted behavior will happen.
But after every two years, a new version of Debian is released. And the new version often brings significant improvements and new features. On a 'clean' system, upgrading from one main version to the next is 'smooth', making you feel like you've just upgraded some non-important packages.
Detailed instructions on how to upgrade Debian
- Before upgrading, clean up sources.list!
- Prepare sources.list to upgrade
- Upgrade Debian
Before upgrading, clean up sources.list!
Some users experience problems when they try to upgrade Debian, such as unable to resolve conflicts between deleted packages, important software, etc. Finally, they only have to uninstall. Put old and install a new version. However, in most cases, it is not a bug with Debian. The reason these users encounter problems is often because they accidentally do some things that break their operating system. The fact that the operating system is still working doesn't mean the package manager has no problems. That's why it's always recommended to remove any reference to third party software from 'sources.list' files before continuing.
Please open this file to edit:
sudo nano /etc/apt/source.list
Delete any references to software outside of the official Debian archive. There are only three lines you need in this file.
If you need a template, copy the example below and modify it as needed.
It is important to keep the current codename of the Debian release! For example, if it's 2021 and you're running Debian Buster, replace stretch with buster or whatever applies to your case.
deb http://deb.debian.org/debian stretch main deb http://deb.debian.org/debian stretch-updates main deb http://deb.debian.org/debian-security/ stretch/updates main
Also, keep the ending strings intact. In this example, the line ends with the string 'main'. But if your current 'sources.list' ends with 'main contrib non-free' , add 'contrib non-free' at the end of each line. In this case, the final result looks like this:
deb http://deb.debian.org/debian stretch main contrib non-free deb http://deb.debian.org/debian stretch-updates main contrib non-free deb http://deb.debian.org/debian-security/ stretch/updates main contrib non-free
To save the file, press Ctrl + X , followed by y and then Enter.
Update package information:
sudo apt update
Upgrade packages:
sudo apt upgrade
If a change like the following image appears, after reading it, you can exit by pressing q .
Remove unnecessary packages:
sudo apt autoremove
Prepare sources.list to upgrade
It is worth noting that you should only upgrade from one main version to the next. For example, you should upgrade Debian 7 to 8 or 8 to 9, not upgrade from 7 to straight 9.
Edit your software source file again.
sudo nano /etc/apt/sources.list
Replace the codename of the current Debian release with the codename of the next version. You can find codename on the Debian distribution list page ( link: https://www.debian.org/releases/ ).
For example, to upgrade Debian 9 to Debian 10, you will change this:
deb http://deb.debian.org/debian stretch main contrib non-free deb http://deb.debian.org/debian stretch-updates main contrib non-free deb http://deb.debian.org/debian-security stretch/updates main contrib non-free
. into:
deb http://deb.debian.org/debian buster main contrib non-free deb http://deb.debian.org/debian buster-updates main contrib non-free deb http://deb.debian.org/debian-security buster/updates main contrib non-free
Save the file and then refresh the package information:
sudo apt update
Upgrade Debian
If you are performing an upgrade on the desktop, log out of the graphical interface. The update process will restart the graphical stack at some point and cause you to lose access to the terminal application.
Log in to the text console. Press ALT + CTRL + F2 or ALT + CTRL + F3 , log in with your username and password, then enter the command on this screen.
Perform safety upgrades first. This step will upgrade all packages without removing anything.
sudo apt upgrade
Please note if there are any conflicts that result in the packages being removed. If you use this command and the next command on some systems, things like graphics stacks can be completely removed. However, that will not happen on 'clean' systems, where you have never installed things outside of the Debian archive.
Some packages come with new configuration files. You will be asked to keep the old configuration or upgrade to a new configuration.
If you have modified the configuration file, you may want to keep or upgrade and then add customizations. However, if you have never touched this file, choose to upgrade the new configuration (enter Y ). The upgrade may contain important improvements, security fixes or changes needed to make the software work. That's why you should install the version of Google maintenance package as often as possible.
Now, perform the full upgrade. This will upgrade the rest of the packages that cannot be updated with the previous command (the reason is that they conflict with old packages or outdated programs already on the system). Full upgrade will remove some old packages to make room for new packages.
sudo apt full-upgrade
After this command, the upgrade will be completed. You can clean up unnecessary packages with the command:
sudo apt autoremove
Finally, restart the computer or server:
sudo systemctl reboot
In most cases, the upgrade process will not encounter any problems. But if you have added third-party software sources to your package manager or installed third-party packages (with commands like dpkg -i something.deb ), you may encounter conflicts. In such cases, you will have to resolve them manually, by removing the previous violation packages with the command:
sudo apt autoremove badpackage
Hope you are succesful.
You should read it
- How to install Debian on a computer
- How to upgrade from Debian 11 'Bullseye' to Debian 12 'Bookworm'
- How to Install Gradle on Debian 10
- Notable changes and additions in Debian 11 'Bullseye'
- Do not destroy the Debian system!
- Debian 10 Buster, New features in Debian 10 Buster
- How to Restart Debian Using the Command Line
- 9 best Debian-based Linux distributions
- How to Install and Use Ansible on Debian 10
- How to Install Debian
- Configure mouse settings on the Debian system
- How to Install Wireshark on Debian 11
Maybe you are interested
CrowdStrike also crippled global Debian and Rocky Linux systems many months ago, but no one noticed!
How to install NVM on Debian
How to install and configure Samba on Debian
How to Configure Firewall on Debian Using UFW
9 best Debian-based Linux distributions
How to upgrade from Debian 11 'Bullseye' to Debian 12 'Bookworm'