What is it with the "dist-upgrade" option of apt-get?
There has always been a bit of confusion when people learn they can do a full upgrade of their distribution from the command line. Most people don't brave such a feat. Some because they don't use the command line, and others because they are afraid an attempt to upgrade from the command line will wind up fubaring their system.Â And new users aren't quite sure what the difference between apt-get upgrade and apt-get dist-upgrade is.
In this Ghacks Linux entry, I am going t dispel the myths and fear of the dist-upgrade command. Of course, as with everything PC-related, you know their are always risks when you do a major upgrade. With that warning out in the open, let's set out to curb a little fear.
First I want to compare the two apt-get options: upgrade and dist-upgrade. The difference between these two is very simple. The upgrade option is used only to install all of the newest versions of the packages already installed on your machine. This is what happens when you see the upgrade upgrade packages through the Update Manager (You know, when you are made aware of notification in your panel and then Update Manager opens to show you whichÂ updates are available for your system.)
The dist-upgrade option is quite different from upgrade. But just what does dist-upgrade do? Simple. The dist-upgrade option not only will upgrade all of the currently installed packages on your system it will also handle the dependency changes with new versions of packages. In other words, dist-upgrade will remove obsolete packages from your system, whereas upgrade will not. This function is out of necessity for upgrading from one distribution release to another.
But doesn't it upgrade my distro?
Not necessarily. Although, by itself, dist-upgrade, will prepare your system for a distribution upgrade, the only way it will actually perform the upgrade to a new release is if you have changed your /etc/apt/sources.listfile to reflect the change. In other words, you have to add the repositories for the new distribution in the sources.list file before this can happen.
Well that sounds simple. Yes it is. But it is not the recommended plan of attack for upgrading to a new distribution. Although it will work, there is a better way...by command. The command do-release-upgrade was created specifically for upgrading the operating system to the latest release via the command line. Of course, before you issue this command you will want to check to see if an upgrade is available with the command sudo do-release-upgrade -d. When you do this you you be informed if a new release is available. If there is a new release available issue the command sudo do-release-upgrade and the upgrade process will begin. Of course this is a rather lengthy process and there are risks involved.You could lose packages you have manually installed (that are not supported by the new release) or (worst case scenario) your system could become unstable.
Distribution upgrades are always tricky. I have had them go exceedingly well and I have had them go very awry. It's a gamble. But now you know exactly how to manage the task from the command line. You are now, officially, dangerous. ;-)Advertisement