Update/Upgrade your Debian distribution

For users who have recently installed a Debian distribution, might have been looking ways to update their systems. In this article, we would discuss how to update as well as upgrade a Debian distribution through command line interface.

Open Terminal and login as superuser by using the command:

su -l

It will ask for superuser’s password. If you don’t have one, then its time to contact your system administrator.

Update your Debian distribution

Once you have successfully logged in, we need to update our systems repositories. Use the command:

apt update

The command assists our system to know the latest version of packages available on Debian’s mirror. So, if we update our system then by default it would install/update the most recent version available for the package.

To upgrade installed packages, we need to run the following command:

apt upgrade

After running the command, it will provide us with the list of packages that have an upgrade available. We are also provided with the size of our upgrade. If your are ready to upgrade, then press Y or otherwise.

When newer version of packages and related dependencies have been installed. Then, it could be possible that we may still have dependencies installed that are no longer required. To remove those installed dependencies run the following command:

apt autoremove

Lastly, all the packages that have ever been downloaded and installed are available in the directory

/var/cache/apt/archives/

If you no longer need these installed packages, and want to free some disk space then run the following command:

apt autoclean

So, next time you want to install the same version of the packages that you previously installed. Then, you have to download that package again as it would no longer be available in archives. If you are not worried about disk space then, perhaps its a good notion to leave the archives directory untouched.

Upgrading your Debian distribution to newer Release

Till now, we have discussed how to update your Debian distribution. When it comes to upgrade, it means moving from one Debian release to another i.e. from Stretch to Buster.

We need to first update the file to move from one stable version of release to another:

nano /etc/apt/sources.list

with the following entries:

http://<domain-name>/debian stable main contrib

where,

replace <domain-name> as per present SourcesList configuration.

Then, save and exit. Run the following command:

apt update

Updating the entries in sources.list file would help us to move to next stable distribution.

Word of Caution: Moving from one stable version to another stable version is possible but, we can’t move from testing and unstable versions to stable version. So, make sure you are not using the testing/unstable versions of Debian. If so, then update the sources.list files accordingly.

Now, run the following command to upgrade to next stable distribution:

apt dist-upgrade

Debian uses a start-stop-daemon program that can restart running packages during a package upgrade. Hence, you don’t need to boot to single user mode or rescue mode to upgrade your Debian distribution.

In conclusion, we have discussed how to update/upgrade your Debian distribution.