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
upgrade like this:
sudo apt update && sudo apt upgrade
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
... update part updates the library of available packages, so that your system knows what is available, and can compare them to what is installed.
... 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.
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
upgrade or both. Be aware that upgrading packages could bring some difficulties on it's own.