Running Updates And Upgrades In Linux
Have you ever wondered why Linux users have to run sudo apt-get update or sudo yum update most times before installing a new software? Linux distributions install software from central repositories using package managers. If you don't update these repositories, your system might run into trouble while installing new packages. Linux applications use shared libraries. Because Linux programs use these libraries, Linux distributions package these the same way they do with executable programs. The downside is that the update schedules for programs and their libraries differ. Developers might make changes to programs or libraries that can alter their behavior. Complicating the different update schedules, every Linux distribution has their own method for releasing software, with rolling-release distros like Arch releasing packages very soon after developers come out with their versions.
If the package repositories haven't been updated, you may run into trouble installing or running new programs that depend on outdated libraries installed on your system. Broken packages on Linux can occur with outdated packages. In this article, we will go over what update and upgrade does and why it is highly recommended to update and upgrade before installing new packages. Even though you usually see update and upgrade together, we will go over what the differences are.
When you install a package, the package manager reads the list and determines the URL of the package to download and contains package version information. The update command updates the package list. If the list isn't updated before installation, the package manager might complain that it cannot find the package in the repository, because it computed the URL based on an old version of the list which contains an older version of the package. Update is also necessary after you change or add repositories, because the system needs to download the list for the new repositories.
Update doesn't make any changes to the system. It only updates the package index file. The package index file is a file or database that contains a list of software packages in the repositories. The repositories are located in
. /etc/apt/sources.list
also contains other lists of packages. Since it only updates the package index file, you can stop it and resume where it left off.
/etc/apt/sources.list
Upgrade is used to install the newest versions of all packages currently installed on the system from the sources listed in
. Packages currently installed with new versions available are retrieved and upgraded. No current packages are removed and packages that are not installed already are installed unless there are dependencies. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will not be upgraded. An update must be performed first so that the package manager knows that new versions of packages are available. Upgrade changes the system and should not be interrupted while running./etc/apt/sources.list
Sometimes, the packages you want to download may not be included in the central repositories. In that case, you have to add a new repository to your system so that it can be recognized by the package management tool. A repository, or repo, is a storage system that contains software packages. In this repo, each package is stored with the corresponding metadata. The metadata contains information about a package such as available versions, dependencies, license, documentation, etc. The metadata maps your install command to the package when you run a command. The package management tool allows you to interact with a repository and manage installed packages.
The default repositories contain the most common and popular packages. A repository stores thousands of packages so there is plenty of software you can install. In some cases, you might not be able to find a package that meets your needs. In these cases, you can search the Internet and find the packages in a third-party repository. Those third-party packages are not managed by central repos. Using a third-party package comes with risk. One of the big problems with external resources is that you have to trust people you don't know. Every single person is a new line of trust, adding more risk. By adding the repository, you may have unstable software.
Executing update gives you a list of packages for all of your repositories and PPA's and to make sure it is up to date. Executing upgrade does an actual software upgrade. It is recommended to run the update command before the upgrade command to update installed packages. Running these two commands makes sure that you get the latest patches and the latest software.