Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 update:

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?

share|improve this question

4 Answers 4

up vote 72 down vote accepted

From apt-get manual:

   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.

In your particular case, I see, for example, that linux-headers is a virtual package that is provided by both linux-headers-3.0.0-12 and linux-headers-3.0.0-13 and that sounds like the kind of package installation and removal handled by dist-upgrade, but not by upgrade.

share|improve this answer

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 with apt-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 kernel linux-image-3.2.0-10-generic installed and linux-image-3.2.0-11-generic appears, the linux-image-generic package gets updated to depend on the newer version. In order to install the new kernel, you need to run apt-get dist-upgrade.

Notice how an apt-get upgrade will say that the kernel packages have been held back. That's the cue for using apt-get dist-upgrade.

share|improve this answer
1  
Perfect! :D Two more questions... what is used by the graphical update manager in Ubuntu? What is the recommended one? –  EApubs Jan 29 '12 at 1:46
3  
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. –  pablomme Jan 29 '12 at 2:10

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.

share|improve this answer
    
Best gist. Still, how to keep a certain package? –  0xC0000022L Nov 15 '13 at 17:06

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 run apt-get upgrade, as it will say that certain packages have been held back. That's your cue to use: apt-get dist-upgrade.

share|improve this answer
3  
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. –  Eliah Kagan Apr 13 '13 at 2:11
1  
You should write your own answer, as that add no clarity to mine. –  david6 Apr 13 '13 at 6:13
2  
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. –  Chan-Ho Suh May 24 '13 at 3:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.