How to upgrade Debian 9 to Debian 10 Buster using the CLI

I have Debian 9.x installed on AWS EC2. How do I upgrade Debian 9 Stretch to Debian 10 Buster using the apt command/apt-get command CLI? How can I upgrade Debian 9 to Debian 10 using ssh client?

Debian Linux 10 “Buster” released. The new version offers updated packages and five years of support. In this release, GNOME defaults to using the Wayland display server instead of Xorg. However, the Xorg display server still installed by default. This page shows how to update Debian 9 Stretch to Debian 10 Buster using command-line options, including upgrading all installed packages.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Debian Linux 9.x
Est. reading time 4 minutes

What’s new in Debian 10?

  • Updated desktop environments such as Cinnamon 3.8, GNOME 3.30, KDE Plasma 5.14, LXDE 0.99.2, LXQt 0.14, MATE 1.20, Xfce 4.12.
  • Secure Boot support greatly improved
  • AppArmor is installed and enabled by default
  • Apache
  • BIND
  • Chromium
  • Emacs
  • Firefox
  • GIMP
  • GNU
  • GnuPG
  • Golang
  • Inkscape
  • LibreOffice
  • Linux
  • MariaDB
  • OpenJDK
  • Perl
  • PHP
  • PostgreSQL
  • Python
  • Ruby
  • Rustc
  • Samba
  • systemd
  • Thunderbird
  • Vim

Upgrade Debian 9 to Debian 10 Buster

The procedure is as follows:

  1. Backup your system. Typically I create a snapshot.
  2. Update existing packages and reboot the Debian 9.x system.
  3. Edit the file /etc/apt/sources.list using a text editor and replace each instance of stretch with buster.
  4. Update the packages index on Debian Linux, run:
    sudo apt update
  5. Prepare for the operating system upgrade, run:
    sudo apt upgrade
  6. Finally, update Debian 9 to Debian 10 buster by running:
    sudo apt full-upgrade
  7. Reboot the Linux system so that you can boot into Debian 10 Buster
  8. Verify that everything is working correctly.

Let us examine all commands step by step to upgrade Debian 9 Stretch to Debian 10 Buster safety running in the cloud or bare metal environment.

Step 1. Backup your system

Warning! Do not skip the backup step. The author and nixCraft are not responsible for data loss and failed installation.

It is crucial to backup all data and system configurations. Cloud-based VMs can be quickly backup and restore using snapshots. I use rsnapshot, which is the perfect solution for making backups on the local or remote servers. Check os version in Linux:
lsb_release -a
Sample outputs:

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

Note down the Linux kernel version too:
uname -mrs
Sample outputs:

Linux 4.9.0-12-amd64 x86_64

Step 2. Update ALL existing installed packages

Before you upgrade your Debian version to 10, you must apply all security patches and pending upgrades to Debian 9 itself Hence, Type the following apt command or apt-get command:
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt --purge autoremove

sudo apt-get update
sudo apt-get upgrade
sudo apt-get full-upgrade
sudo apt-get --purge autoremove

Reboot the Debian 9.x stretch to apply the kernel and other updates:
sudo reboot

Step 3. Update /etc/apt/sources.list file

Before starting the upgrade you must reconfigure APT’s source-list files. To view current settings using the cat command:
cat /etc/apt/sources.list
Sample outputs:

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

The stretch indicates that we are using an older version. Hence, we must change all the references in this file from Stretch to Buster using a text editor such as vim:
vi /etc/apt/sources.list
I prefer to use sed tool, but first backup all config files using the cp command:
sudo cp -v /etc/apt/sources.list /root/
sudo cp -rv /etc/apt/sources.list.d/ /root/
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*
### see updated file now ###
cat /etc/apt/sources.list

APT source-list files updated to use buster

Updating the package list

Simply run:
sudo apt update

Step 4. Minimal system upgrade

A two-part process is necessary to avoid the removal of large numbers of packages that you want to keep. Therefore, first run the following:
sudo apt upgrade

Just follow on-screen instructions. During the upgrade process, you may get various questions, like “Do you want to restart the service? ” OR “keep or erase config options” and so on. For example, I got a screen as follows indicating new changes:

Press ‘q‘ to exit and further you may see additional screens:


Step 5. Upgrading Debain 9 to Debian 10

In addition, minimum upgrades we need to do full upgrades to finish the whole Debian 9 to Debian 10 update process. This is the main part of the upgrade. In other words, execute the following command to perform a complete upgrade of the system, installing the newest available versions of all packages, and resolving all possible dependency:
sudo apt full-upgrade

Reboot the Linux system to boot into Debian Linux 10 buster, issue:
sudo reboot

Step 6. Verification

It is time to confirm the upgrade. Run:
uname -r
lsb_release -a

Sample outputs:

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

Finally, clean up outdated packages using the apt command/apt-get command:
sudo apt --purge autoremove


And there you have it. We have successfully upgraded to Debian Linux 10. Updated Debian 10 version always brings new features and hardware support via Linux kernel. Hence, one must evaluate needs and then do upgrades. Debian project also posted an in-depth guide that explains other issues one might face during installation.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • SomeUser Feb 14, 2021 @ 8:35

    All the instructions are present in step 2.
    It is a little confusing. It would be better if step 3 comes before step 2.

    Or remove step 2 and add it as a summary.

    • 🐧 Vivek Gite Feb 14, 2021 @ 8:41

      No. They are correct. In step # 2, you update existing packages on Debian 9. After that you move to step # 3 to edit the config file to get actual Debian 9 to Debian 10 packages.

  • Per E. Mar 8, 2021 @ 18:24

    Great instruction! I have now upgraded three Raspberries.

    I would be nice to be able to answer “N” in advance on all the questions about keeping the old config files.

    • 🐧 Vivek Gite Mar 8, 2021 @ 18:39

      You can do that as follows (i never tried but option availble):

      export DEBIAN_FRONTEND=noninteractive
      sudo apt -o Dpkg::Options::="--force-confold" --force-yes -y full-upgrade
  • Alexander Mejia Mar 12, 2021 @ 18:09

    sooooooooooo greatttt works flawlessly…………..

  • Camps Apr 9, 2021 @ 12:26

    Thanks for this!
    After upgrading, I cannot connect to the NIS server.

    Any ideas?

    • 🐧 Vivek Gite Apr 10, 2021 @ 8:09

      Check your NIS server log and client config. Some times syntax changes between two versions. Log file is the way to debug this issue.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum