I was wondering why upgrade
sometimes doesn't want to upgrade certain parts of the system, while dist-upgrade
does. Here's an example after running apt-get upgrade
:
apt-get upgrade
:
rimmer@rimmer-Lenovo-IdeaPad-S10-2:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
linux-generic linux-headers-generic linux-image-generic
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
versus apt-get dist-upgrade
:
rimmer@rimmer-Lenovo-IdeaPad-S10-2:~$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
linux-headers-3.0.0-13 linux-headers-3.0.0-13-generic
linux-image-3.0.0-13-generic
The following packages will be upgraded:
linux-generic linux-headers-generic linux-image-generic
3 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 48.5 MB of archives.
After this operation, 215 MB of additional disk space will be used.
Do you want to continue [Y/n]?
In other words, why can't this be performed by upgrade
?
From
apt-get
manual:And with the newer
apt
tool available from 14.04 onwards:In your particular case, I see, for example, that
linux-headers
is a virtual package that is provided by bothlinux-headers-3.0.0-12
andlinux-headers-3.0.0-13
and that sounds like the kind of package installation and removal handled bydist-upgrade
, but not byupgrade
.apt-get upgrade
is restricted to the case where packages are to be replaced by newer versions, but no package needs to be added or removed. A new version of Firefox, for instance, should be installable withapt-get upgrade
.However
apt-get upgrade
will refuse to work when there are additions or removals required by the updated versions. For example, when you have kernellinux-image-3.2.0-10-generic
installed andlinux-image-3.2.0-11-generic
appears, thelinux-image-generic
package gets updated to depend on the newer version. In order to install the new kernel, you need to runapt-get dist-upgrade
.Notice how an
apt-get upgrade
will say that the kernel packages have beenheld back
. That's the cue for usingapt-get dist-upgrade
.Basically upgrade will only upgrade existing packages from one version to another. It will not install or remove packages, even if doing so is required to upgrade others. In the case of kernel updates, upgrading the linux-generic package requires installing the new linux-3.0.0-13-generic package, and since upgrade refuses to install or remove packages, it refuses to upgrade linux-generic.
Sometimes various incompatibilities between packages will require some packages to be removed in order to upgrade others, and that will also require dist-upgrade. Kernel updates will always require dist-upgrade because of how they are handled. Rather than have a kernel package that gets updated, an entirely new kernel package is created each time, and the kernel metapackage is updated to depend on the new kernel package instead of the old. This was done so that you keep the old kernel versions around so that in case there is a problem with booting the new kernel, you can choose the old one from the boot menu and recover.
The
apt-get upgrade
command will normally only install updates (or fixes) to currently installed packages. Typically a new release of Mozilla Firefox, for instance, would be installed with this command.However
apt-get upgrade
will NOT generally install new releases, where major changes (including removal of packages or GRUB update is required). For example, when a new Linux kernel (linux-image-3.x.x-xx-generic, etc.) is available, the package will not get installed.In order to install the new kernel, you will need to run
apt-get dist-upgrade
. You will be notified when you runapt-get upgrade
, as it will say that certain packages have been held back. That's your cue to use:apt-get dist-upgrade
.Your best option is:
-which auto-handles the dependencies when upgrading packages; whereas:
-does NOT auto-handle dependencies when upgrading packages.
Short answer those who want the exact point
apt-get update
apt-get upgrade
apt-get dist-upgrade
apt-get full-upgrade
apt-get do-release-upgrade
ref:https://linuxhint.com/apt_get_upgrade_dist_upgrade/#:~:text=Unlike%20apt%2Dget%20upgrade%20command,sudo%20apt%2Dget%20dist%2Dupgrade