In an earlier article, we looked at the APT command and various ways that you can make use of the package manager to manage packages. That was a general overview, but in this guide, we pause and shine the spotlight on 2 command usages. These are apt update and apt upgrade commands.
The apt update and apt upgrade are two of the most commonly used yet misunderstood commands for many Linux users. For some, these play the same role, which is not the case. In this guide, we seek to distinguish the differences between the two and how each one of them is used.
1) apt update command
This is a command that is mostly invoked after a fresh system install or before installing a new software package. The apt update command updates the package index of a Linux system or package lists. It does not upgrade any packages, as some Linux users are misled to believe.
The package index file is a file or database that contains a list of software packages defined in repositories located in the
/etc/apt/sources.list file. Other lists of packages are located in the
It's extremely safe to run this command. You can resume from where is stopped if for some reason aborted or unplugged.
Use the cat command on terminal to view the sources list file.
$ cat /etc/apt/sources.list
To update the package lists, invoke the command:
For Ubuntu 18.04 and later releases
$ sudo apt update
For Ubuntu 16.04 and earlier releases
$ sudo apt-get update
2) apt upgrade command
Need to upgrade your software packages to their latest versions? Then apt upgrade is the command to execute. The apt upgrade command , without any arguments, upgrades all outdates packages residing on your system to their latest versions.
If any dependences are required, the command also triggers the installation of new packages. Along with that, apt upgrade also installs all the security updates needed by your system, and this fortifies the security of your system.
To list packages that are due for upgrade, run the apt list --upgradable command. In fact, this is a hint that is displayed at the very end of the apt update output.
So, to have a view of packages ready to be upgraded, run:
$ sudo apt list --upgradable
To upgrade all the outdated packages and apply security patches, run the command:
$ sudo apt upgrade
Its more safe not to disrupt or about the apt upgrade while its running.
Few things to keep in mind:
Do you have a good backup to revert back if it breaks for some reason?
Are you sending logs to another remote system?
Any manually compiled software?
The apt update command is used in synchronizing the package lists on your system. It fetches the latest package lists for PPAs and repositories on your system and ensures that they are up to date.
The apt upgrade command upgrades packages to their latest versions and installs new packages if they are required as dependencies. It does not remove any packages and if any are earmarked to be removed, it skips them.