Difference Between apt-get upgrade and dist-upgrade

Written by: Winnie Ondara   |   Last updated: July 7, 2022

In this guide, we look at apt-get upgrade and apt-get dist-upgrade commands and seek to understand the difference and when each is used.

1. apt-get upgrade

According to the man pages, the command apt-get upgrade ( for older Debian/Ubuntu releases) or apt upgrade ( for newer releases such as Ubuntu 18.04 and later & Debian 10) is used to upgrade currently installed software packages to their latest versions. Under no circumstances are existing packages removed. If a package upgrade requires the removal or the installation of additional packages, the upgrade of the installed package is skipped and the package remains untouched in its current version.

Before upgrading the packages, it's always required to update the package index first. This updates the package lists in the /etc/apt/sources.list file and /etc/apt/sources.list.d directory.

sudo apt-get update

Then

sudo apt-get upgrade
upgrade system packages
upgrade system packages

If you want to upgrade a specific and leave the rest intact simply use the syntax below:

sudo apt-get upgrade package-name

2. apt-get dist-upgrade

This is an enhanced version of the apt-upgrade command. Apart from upgrading existing software packages, it installs and removes some packages to satisfy some dependencies. The command includes a smart conflict resolution feature that ensures that critical packages are upgraded first at the expense of those considered of a lower priority.

To be 100% safe make sure to carry out an upgrade on a test environment before running on production.

sudo apt-get dist-upgrade
apt-get dist-upgrade command
apt-get dist-upgrade command

The main distinction between apt-get upgrade and apt-get dist-upgrade is that in the former, none of the packages are removed. Software packages with newer versions are upgraded and none whatsoever are removed. In the latter, some newer packages are installed, and some are removed to satisfy certain dependencies.

Conclusion

The apt-upgrade command will always seek to upgrade the installed software packages if newer versions are found in the repositories. It doesn't trigger the removal of any packages. Meanwhile, apt-get dist-upgrade will delete some packages when required to do so during the upgrade of the software packages. We hope that you now have a clear understanding of the two commands and how each differs from the other. Your feedback on this brief tutorial is highly welcome.

About The Author

Winnie Ondara

Winnie Ondara

Winnie is a Linux technical writer with over 3 years of experience with various Linux distributions and writing technical guides in Linux. She is passionate about FOSS technologies and always endeavor to learn new technologies. During my free time, I watch movies, listen to music, and catch up with tech news.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment