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.
Differences
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
“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.”
I’m pretty sure you meant to say “sudo do-release-upgrade -c” here, -d (= Devel Release) actually starts the upgrade process.
Thanks, really useful information. Also it works for Trisquel (https://trisquel.info/en).
Thanks for the article, it did upgrade my knowledge @ apt-get upgrade !! ;))
Thanks for clarifying. I had a problem with broken packages and couldn’t update to the latest version of firefox. So I went on the mint IRC channel to ask for help and someone mentioned dist-upgrade. This fixed the broken package and completed the update! I also was told to execute apt-get install -f, does anyone know what that does?
You have to run “do-release-upgrade -c” for only checking if there is a new release available. The parameter -d is for upgrading to the latest devel release (alpha, beta or rc).
man I setup this old p4 in my closet for projects during a college course a year and a half ago- I originally put a desktop distro of ubuntu on it and was managing it via remote desktop if you can believe it. Being new to linux in general much less bash, you a learn a bit more and a bit more at a time, the shell being clearly easier, quicker, and sans the obtuse extra overhead of desktop software totally in-germane to server use. Finally though, I feel like I’m “dangerous” thanks Mr. Ghacks!
Cool!
Thanks for the info.
Best regards.
From the official Ubuntu documentation of do-release-upgrade:
“It is also possible to use do-release-upgrade to upgrade to a development version of Ubuntu. To accomplish this use the -d switch: ”
From what I can tell that command will not just check to see if a new version is available, but will perform an upgrade to the current alpha/beta.
Nice! I didn’t know about the whole “do-release-upgrade”-command, but now I know! Thanks :)
thanks. very informative