1

As far as I remember, I always run sudo apt update or sudo apt-get update before installing a new package.

When should I run both update and upgrade like this:

sudo apt update && sudo apt upgrade
6

You run sudo apt update to refresh the list of available packages.

You run sudo apt upgrade to upgrade all installed packages.

Obviously you always run update before upgrade to use the latest list.

  • So, sudo apt update only prepares a list of upgradeable packages? – BlueSkies Nov 21 '19 at 22:45
  • 1
    It downloads the latest list and compares with the installed package versions? Nothing else. You are correct. If you plan to install a new package, you need to get the list. Otherwise it may be not found. – Pilot6 Nov 21 '19 at 22:48
4

The ... update part updates the library of available packages, so that your system knows what is available, and can compare them to what is installed.

The ... upgrade fetches the packages from the repositories, and installed or 'upgrades' the packages.

Presumably you would only need the ... upgrade if there were packages to upgrade, however if there are no upgradeable packages, apt exits without error.

3

I think the man page explains it well:

   update (apt-get(8))
       update is used to download package information from all configured
       sources. Other commands operate on this data to e.g. perform
       package upgrades or search in and display details about all
       packages available for installation.

   upgrade (apt-get(8))
       upgrade is used to install available upgrades of all packages
       currently installed on the system from the sources configured via
       sources.list(5). New packages will be installed if required to
       satisfy dependencies, but existing packages will never be removed.
       If an upgrade for a package requires the remove of an installed
       package the upgrade for this package isn't performed.

So depending on your needs, you would want to use update or upgrade or both. Be aware that upgrading packages could bring some difficulties on it's own.

  • I'm trying to undestand it. Update prepares a list of new versions of packages, but doesn't install them. Upgrade installs the new versions. – BlueSkies Nov 21 '19 at 22:43
  • update updates the information from the repositories, not necessarely the newer packages. For example if you want to install package_x, you may need to update first, so the package is available, after adding some entry to sources.list. Later you may want to upgrade package_x if there's a new version available. – guillermo chamorro Nov 21 '19 at 22:49
  • but doesn't install them*|*Upgrade installs the new versions that's correct – guillermo chamorro Nov 21 '19 at 22:55
  • In all cases of installation of a new package, I was running apt update then apt install, and NOT apt upgrade. That means that none of the upgradable packages were upgraded – BlueSkies Nov 21 '19 at 23:29

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.