The “apt” package manager can perform the update and upgrade operations. The “apt update” loads the latest while the “upgrade” installs those updates. The “apt update” and the “apt upgrade” are recommended to perform before the software package installation and removal to keep the system up to date.
This post explains the details of “apt update” and “apt upgrade” with the following outline.
- apt Update in Linux
- apt Upgrade in Linux
- List Upgradeable Packages
- Difference Between apt Update and Upgrade
- apt update and apt upgrade in One Command
What is apt Update?
The “apt update” command provides the list of package index file updates in the default repositories. This command is generally used before installing the software application to get its updated version from the repository.
The command needs the superuser privileges, i.e., either root user or “sudo” during the execution:
$ sudo apt update
The output shows the latest list of available source packages. The information is collected from the “ /etc/apt/sources.list” repository, and the other packages list is from the “/etc/apt/sources.list.d” directory
The output may also contain three keywords at the start of the package’s name that is defined here:
- Hit: Shows that there is no need to change the package version.
- Get: Displays that the latest version of the desired package is present.
- Ign: Indicates the latest package version and ignores it.
What is an apt Upgrade?
The “apt upgrade” command is useful in upgrading all the packages to the latest version displayed by the “apt update” command. It also downloads the new dependencies if required for any package. In addition, this command installs the security updates needed for our Linux system.
Simply execute this command with the “sudo” to upgrade all the outdated packages:
$ sudo apt upgrade
The output shows that “247” packages need to be upgraded. Enter “y” if the user wants to continue the upgradation.
List the Details of Upgradeable Packages
The “apt upgrade” command upgrades the packages. If you want to get the list the details of the packages that can be upgraded, use the command:
$ sudo apt list --upgradable
Difference Between apt Update and Upgrade
The “apt update” tells the Debian/Ubuntu system to browse the available packages, update list and display them on the terminal. It downloads the package information from the default repository and the PPA’s from the internet.
On the other hand, the “apt upgrade” downloads all the packages’ latest versions into the system. It takes up additional space on the system because it does not remove the old dependencies.
“apt update” and “apt upgrade” in One Command
The ampersand sign (AND operator) can be used between the apt update and the apt upgrade (any two Linux commands) to update and upgrade the packages.
$ sudo apt update && sudo apt upgrade
The above command has provided the updated list of packages, and the upgradation has been started.
In Ubuntu/Debian-based Linux systems, the “apt update” synchronizes the package’s list and loads the latest packages. While the “apt upgrade” upgrades the packages to the latest release. All the details and the functioning of the apt update and upgrade have been discussed.