apt update vs. apt upgrade: What Are the Differences?
The apt command – short for “Advanced Package Tool” – is a widely used package manager for Debian-based Linux distributions, such as Ubuntu and Debian itself. It’s used to manage and update software packages on a Linux system, and comes with a handful of useful subcommands, including apt update and apt upgrade.
While both apt update and apt upgrade are important tools for keeping your Linux system up-to-date, they perform distinct functions. In this article, we’ll explore what these differences are and when to use each command.
The apt update command
When you run apt update, the package manager retrieves an updated list of available software packages from the repositories configured on your system. In other words, it checks with the software sources you have enabled and downloads a catalog of new software, package versions, and dependencies that can be installed through the apt package manager.
Once apt update has completed the update process, you’ll be able to run apt-cache search, apt-cache show, and apt install or apt remove commands to manage your software packages more efficiently, making sure you always work with the latest available versions.
The apt upgrade command
While apt update simply updates your package list, apt upgrade goes a step further and updates any installed software packages that have been updated in the repositories. In other words, the command scans the list of available packages that have been updated since you last ran apt update and checks to see if there are any upgrades to apply. If upgrades are available, it downloads and installs them on your system, upgrading any outdated package versions you might have.
In essence, apt upgrade performs a system-wide software package upgrade, while apt update merely updates your list of available software packages.
When to use each command
In general, you should run apt update before running apt upgrade. This will ensure that your list of available packages is up-to-date and that your system can find the latest software package versions. Without running apt update first, you risk installing software that’s out of date or outdated packages that may contain security vulnerabilities.
Once you’ve run apt update, you can check if there are any upgrades by running apt list –upgradable. This command will tell you which software packages have newer versions available. If you see packages that you’d like to upgrade to, you can run apt upgrade to download and install the new versions.
It’s also worth noting that even if you don’t run apt upgrade manually, your system will still attempt to upgrade installed packages periodically (depending on your system settings). However, it’s still a good idea to keep an eye on any pending package upgrades and run the apt upgrade command regularly to ensure your system is always up to date.