What is "dist-upgrade" and why does it upgrade more than "upgrade"?
I was wondering why
upgradesometimes doesn't want to upgrade certain parts of the system, while
dist-upgradedoes. Here's an example after running
[email protected]:~$ 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.
[email protected]:~$ 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 upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version. An update must be performed first so that apt-get knows that new versions of packages are available. dist-upgrade dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.
And with the newer
apttool available from 14.04 onwards:
full-upgrade full-upgrade performs the function of upgrade but may also remove installed packages if that is required in order to resolve a package conflict.
In your particular case, I see, for example, that
linux-headersis a virtual package that is provided by both
linux-headers-3.0.0-13and that sounds like the kind of package installation and removal handled by
dist-upgrade, but not by
I didn't knew about `apt` either but it seems to be a completely diffrent command according to the man page he linked
@nobar You don't see because it is an option of `apt` and not of `apt-get`... :-) Try `man apt`.
Okay, I searched and the earliest link I found is for Ubuntu 15.10 (which came out end of 2014 which seams reasonable with Jessie testing) http://manpages.ubuntu.com/manpages/wily/en/man8/apt.8.html
Small correction. I guess Ubuntu is built from Testing or Unstable branches. In either case it is based on develop versions of Debian and does not necessarily wait for the Stable branch.
apt-get upgradeis 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 with
apt-get upgradewill refuse to work when there are additions or removals required by the updated versions. For example, when you have kernel
linux-image-genericpackage gets updated to depend on the newer version. In order to install the new kernel, you need to run
Notice how an
apt-get upgradewill say that the kernel packages have been
held back. That's the cue for using
Perfect! :D Two more questions... what is used by the graphical update manager in Ubuntu? What is the recommended one?
The graphical utility, `update-manager`, does not use `apt-get` directly; instead it works with a backend called `aptdaemon`. The standard abilities of `update-manager` are a mix of the `upgrade` and `dist-upgrade` modes of `apt-get`: it can add but not remove packages - it invokes the "Partial upgrade" tool when removals are required. When using the command line, use `apt-get upgrade`. If you see it reports that packages have been "held back", run `apt-get dist-upgrade` to pick up the remaining updates.
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.
apt-get upgradecommand 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.
apt-get upgradewill 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 run
apt-get upgrade, as it will say that certain packages have been held back. That's your cue to use:
This is misleading. `dist-upgrade` will not upgrade to a new release unless `sources.list` has been modified accordingly (and even then, that's not a supported way to upgrade in Ubuntu). When a new kernel is installed with `dist-upgrade`, that's not a *new release of Ubuntu*. It's just a *new package.* Furthermore, the claim "or GRUB update is required" is false. `sudo apt-get upgrade` is perfectly capable of upgrading packages in a situation where GRUB must be updated, so long as no packages are removed and new packages are installed. `update-grub` is run automatically, as always.
Besides what Eliah mentioned, the essential point is that `apt-get upgrade` will not remove or add packages. If a fix to a package requires a new package, the update will be held back. pablomme's answer, which you revised to be less accurate, is better and I'd advise readers to go to that one.
Correction: `apt-get upgrade` will never *install* or *remove* any packages. Kernel upgrades are packaged as new packages and as a result, `apt-get upgrade` will never upgrade the kernel. The fact that kernel upgrade does "major" changes such as GRUB configuration is not the reason for the difference between `upgrade` and `dist-upgrade`.