11

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.

1 Answer 1

14

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.

2
  • 1
    "This could in turn remove some package(s) that is needed by another application, that's why it is not recommended always." Why can that happen? Will APT not know about the dependency? And in which case are packages removed? If they were auto-installed and not anymore needed? Apr 27, 2022 at 7:30
  • Packages are removed if they conflict with any dependencies that are installed as part of the dist-upgrade, not just auto-installed packages. It is not as concerned with affecting old dependencies as it is conflicts affecting new dependencies. It does not auto-remove packages that are no longer needed.
    – Lee3
    Feb 1 at 20:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .