When to Run "Sudo Apt Update" and When "Sudo Apt Update && Sudo Apt Upgrade"?
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...
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
3 Answers
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.
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.
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.