6

I'm fairly new to Ubuntu, and I was getting the "packages held back" message on an apt-get upgrade. I came across several answers that mentioned using dist-upgrade instead, but some of them warned that this could be dangerous, or at least perform more of an upgrade than you might want.

I read the man page and found the "--with-new-pkgs" flag for apt-get upgrade, and in my case it did the trick: it installed some new packages, with a prompt informing me what packages would be installed and asking me if I wanted to continue.

It seems to me like this is may be a safer option than doing dist-upgrade -- am I correct? Using dist-upgrade could remove packages, whereas when I ran upgrade --with-new-pkgs, it simply informed of a package that could be removed and told me to run 'apt-get autoremove' to remove it.

7

Yes, it is safer to some extent.

The core purpose of upgrade --with-new-pkgs and dist-upgrade is to upgrade a package to the latest version and satisfy dependencies in the process.

dist-upgrade takes the ambitious route of installing new packages and/or removing installed packages to satisfy dependencies. This could in turn remove some package(s) that is needed by another application, that's why it is not recommended always.

On the other hand, upgrade will just try to upgrade the package without installing/removing anything from the system. upgrade --with-new-pkgs adds the installing new package capability to upgrade i.e. to satisfy dependency it can install new package(s) but will not remove anything.

So we can put it in a simple expression (the initial apt-get is omitted):

upgrade --with-new-pkgs == dist-upgrade - removal_capability

Note that while upgrading kernel you will still need dist-upgrade.

Also autoremove removes the packages that were installed as dependencies (marked as auto) and no longer needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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