Site icon TechGit

What’s the difference between apt-get upgrade vs dist-upgrade?

You’ll often see two of common ways of updating Debian and Ubuntu-based distributions:

The apt-get update part updates the local package cache and thus tells your system about the packages that can be upgraded.

However, many Linux users get confused between the use of apt-get upgrade and apt-get dist-upgrade.

Are they the same, or is there a difference? In which cases should you use apt-get upgrade and when should you use apt-get dist-upgrade?

In this article, I’ll explain the difference between apt-get upgrade and dist-upgrade. I’ll also discuss how apt upgrade and apt full-upgrade do things differently.

Difference between apt-get upgrade vs apt-get dist-upgrade

Both upgrade and dist-upgrade are used for upgrading the installed packages on the system. However, apt-get upgrade command cannot install a new package or remove an installed package from the system. The dist-upgrade, on the other hand, can install new packages or remove existing packages if required.

It also means you cannot upgrade the Linux kernel version with apt-get upgrade. Why? Your system keeps at least two kernels at a time. Because when there is a new kernel version is available, it is installed along with the one which is already in use.

Since it involves installing new packages, apt-get upgrade doesn’t upgrade the kernel.

apt-get upgrade cannot 'upgrade' kernel versionapt-get upgrade cannot 'upgrade' kernel version
apt-get upgrade cannot ‘upgrade’ kernel version

The dist-upgrade is a superset of upgrade. Apart from the upgrade function, it can also intelligently handle changes in the package dependencies. This includes removing dependency packages that are no longer necessary or resolving conflicts between packages that arose because of changes in the dependencies. It can also install new packages if required.

You can see in the screenshot that running apt-get dist-upgrade not only upgrades installed packages but also installs the new kernel version.

apt-get dist-upgrade can upgrade kernel versionapt-get dist-upgrade can upgrade kernel version
apt-get dist-upgrade can upgrade kernel version

It’s not just limited to kernel upgrades. When your system encounters scenarios where it has to install or remove (dependency) packages for upgrading the installed packages, dist-upgrade helps you. If you see packages have been kept back message, you can run the dist-upgrade or run apt-get install on those packages explicitly.

packages-have-been-kept-back-6804169packages-have-been-kept-back-6804169

Also, if you are looking to upgrade the distribution version, you should use dist-upgrade before starting the distribution upgrade so that all dependencies are handled properly. This DOES NOT mean that you run dist-upgrade command and your Ubuntu is upgraded to 22.04 from 20.04.

To summarize:

Why not use dist-upgrade all the time then?

Now, this is the real question. If the dist-upgrade is the superior command and does all that apt-get upgrade does, why not use it all the time? Why even bother using apt-get upgrade at all?

The answer is stability and predictability.

If you are a desktop user, you may not bother much. But suppose you are a system admin managing mission-critical servers running various services with different configured software. In that case, you cannot let the machine decide the removal of packages, no matter how ‘intelligent’ or ‘smart’ it is.

You don’t want your meticulously configured system to behave strangely because some package was removed automatically by apt.

Also, there was a time when upgrading kernel was also a big deal. It was up to sysadmins to determine if the installed kernel version would be upgraded or not. Ubuntu and other distributions have made it slightly better in recent times.

So, does this means that as a desktop Linux user, you can ditch apt-get upgrade and rely on dist-upgrade all the time? I have a better suggestion here.

Use the apt command instead

No, seriously. apt-get is a legacy, low-level command that can do many things. It is suitable to be used in scripts by other tools or sysadmins.

The apt command is a simplified version and is aimed toward regular, casual users. It does things a bit better and simpler than apt-get.

For updating your Ubuntu system, use this command:

sudo apt update && sudo apt upgrade

Unlike apt-get upgrade, the apt upgrade can install new packages and hence it can upgrade the Linux kernel version.

There is also apt full-upgrade which is equivalent to dist-upgrade.

Was it clear?

I would advise reading a bit more on the apt and apt-get commands. Here are a few articles to help you out:

I hope I was able to make things clear and you have a better understanding of the difference between apt-get upgrade and dist-upgrade.

But if that’s not the case and you still have some questions, please let me know in the comment section.

Original Article

FacebookTwitterTumblrRedditLinkedInHacker NewsDiggBufferGoogle ClassroomThreadsXINGShare
Exit mobile version