How to Upgrade Debian

Upgrade Debian Featured

For approximately two years, Debian remains relatively unchanged. Program versions and features remain the same for this duration. Security fixes get backported. Sometimes, exceptions are made for rare situations where a package might need new features. For example, a driver may get upgraded to add support for more hardware. But it rarely happens.

Keeping things constant has its advantages. It makes the operating system dependable. You almost never encounter bugs. Things almost never break after updating packages. No new features also means no unexpected surprises/behavior.

But every two years (approximately) a new Debian version is released. And it often brings significant improvements and new features you may want or need. Although the operating system is often described as “rock solid,” for reasons mentioned above, the upgrade process is also rock solid. On a clean system the upgrade from one major version to the next is so smooth, it feels like you just upgraded a few unimportant packages.

Before Upgrading, Clean Up sources.list

Some users encounter issues when they try to upgrade. They get unresolvable package conflicts, important software gets removed, and so on. They end up preferring to just remove the old installation and fresh-install the new version. However, most of the time this isn’t Debian’s fault. The reason they encounter problems is often because they did one or more of these things to break their operating system. Just because it seems to be working doesn’t mean that the package manager isn’t suffering in silence. That’s why it’s recommended to remove any reference to third-party software from your “sources.list” files before continuing.

Open the file for editing:

sudo nano /etc/apt/sources.list

Remove any references to software outside Debian’s official repositories. There are only three lines you need in this file.

Upgrade Debian Sources List Example

If you need a template, copy the example below and modify it according to your needs.

It’s very important that you preserve the current codename of your Debian release! So, if it’s year 2021, and you’re running Debian Buster, replace stretch with buster, or whatever applies to you.

deb stretch main
deb stretch-updates main
deb stretch/updates main

Also, preserve the ending strings. In this example the line ends with the string “main.” But if your current “sources.list” strings end with “main contrib non-free,” then add “contrib non-free” at the end of each line. In this case your end result might look like this:

deb stretch main contrib non-free
deb stretch-updates main contrib non-free
deb stretch/updates main contrib non-free

To save the file, press Ctrl + X, followed by y and then Enter.

You can read more about the sources.list on Debian’s wiki.

Update package information:

sudo apt update

Upgrade your packages:

sudo apt upgrade

If a changelog resembling the following picture appears, after you read through it, you can exit by pressing q.

Upgrade Debian Changelogs

Remove unnecessary packages:

sudo apt autoremove

Prepare sources.list for Upgrade

It’s worth noting that you should only upgrade from one major version to the next. Example: you should upgrade Debian 7 to 8, or 8 to 9, but not 7 to 9.

Edit your software sources file again.

sudo nano /etc/apt/sources.list

Replace the codename of your current Debian release with the codename of the next. You can find codenames on Debian’s list of releases page.

For example, to upgrade Debian 9 to Debian 10, you would change this:

deb stretch main contrib non-free
deb stretch-updates main contrib non-free
deb stretch/updates main contrib non-free

to this:

deb buster main contrib non-free
deb buster-updates main contrib non-free
deb buster/updates main contrib non-free

Save the file and then refresh package information:

sudo apt update

Upgrade Debian

If you are doing this on your desktop, log out from your graphical interface. The update process will restart your graphical stack at some point, which will make you lose access to your terminal application.

Log in to the text console. Press ALT+CTRL+F2 or ALT+CTRL+F3, log in with your user and password and enter commands on this screen.

Perform a “safe upgrade” first. This tries to upgrade all packages without removing anything.

sudo apt upgrade

Pay close attention to see if there are any conflicts leading to necessary packages being removed. This, and the next command, is where on some systems things like the graphical stack may be entirely removed. It shouldn’t happen on clean systems where you never installed things outside of Debian’s repository, though.

Some of the new packages come with new configuration files. You will be asked if you want to keep your old configuration or upgrade to the new one.

Upgrade Debian Configuration Changes

If you made modifications to the configuration file, you may want to either keep it or upgrade it and later re-add your customizations. If you never touched the file, however, select to pull in the new configuration (type Y). It may have important improvements, security fixes, or required changes for the software to work. That’s why it’s recommended that you “install the package maintainer’s version” as often as possible.

Now, do a “full upgrade.” This will upgrade the rest of the packages that couldn’t be updated by the previous command. That is because they conflict with older packages or obsolete programs you have on your system. The full upgrade will remove some old packages to make room for the new.

sudo apt full-upgrade

After this, the upgrade is complete. You can clean up unnecessary packages with:

sudo apt autoremove

Finally, reboot your computer/server:

sudo systemctl reboot


In most cases this should work without any issues. But if you had third-party software sources added to your package manager, or installed third-party packages (with commands such as dpkg -i something.deb), you may run into conflicts. In such cases you will have to solve these manually by removing offending packages first (sudo apt autoremove badpackage).

Also, if you want to read more details about upgrading to a new release, Google something like “Debian stretch upgrade.” Of course, replace codename “stretch” appropriately in that search. You will find a page like this one, detailing the upgrade path from one release to another.

Alexandru Andrei

Fell in love with computers when he was four years old. 27 years later, the passion is still burning, fueling constant learning. Spends most of his time in terminal windows and SSH sessions, managing Linux desktops and servers.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox