What is a Package Manager in Linux

Written by: Linuxopsys   |   Last updated: June 23, 2022

There are numerous Linux flavors are available to use. Each distribution uses different tools and utilities to handle software installation, upgrade, and removal. Different Linux operating systems use different software package archives in remote repositories. Linux package managers act as the middle man who fetches these software packages from repositories and manipulates them on behalf of the end-users.

In this guide, we are going to learn about Linux packages, package managers, and their usage.

What is a Linux Package Manager

Linux uses the package management concept to handle the lifecycle of software installation to uninstallation. The package manager is the middle man that serves end-users. It can be a command-line utility or a graphical interface which takes care of software installation, uninstallation, update, and configuration. It is beneficial to know multiple package managers and how they work.

The package manager is not limited to Linux operating systems. It has been used in python, PHP, and many more environments. The package manager's general responsibility is to fetch software packages or units from respective sources. Then manipulate the software package as per users' instructions. There are several sources available for different Linux distributions. These repositories consist of different software package formats for different purposes.

The following figure illustrates the role of a Linux package manager.

what is a Linux package manager

As shown in the above illustration, the end-user has access to the local package manager utility. They can enter commands or click on a graphical interface to access these remote repositories. The package manager’s job is to go, talk to the package repository and perform the actions on behalf of the end-user.

What is a package

A Linux software package encapsulates a specific command-line program, third-party software library, or standalone application. A Linux package consists of several files which are going to be used by the local package manager program. Old days, you might need to find the source code for a given software application and compile it on your own. Then, you need to take care of the dependency tree too. It was a cumbersome process for end-users and consumed time. 

The packaging concept makes life easier for end-users by packaging the software application with pre-compiled source code or binary executable, dependency trees, and metadata. Usually, we call these bundled units software package archives. The Linux operating system vendors introduced various package types such as .deb, .rpm, and .tgz. The mentioned packages use by many package managers to download necessary dependency programs before installing them.

what is a package in Linux

Some Common Linux Package Managers

There are several Linux distributions available in the market. Each of these operating systems maintains its flavors of Linux packages. Red Hat has introduced the .rpm package type that is used by Red hat package managers. The .deb package type was introduced by Debian too. There are different package managers implemented to manipulate each of the package types. Some are common package managers which can be used as a base for many other packages. There are several third-party package managers also available to use. Hence, it is beneficial to know about each package manager.

APT

The APT stands for Advanced packaging tool. It is a widely used package management system that is derived from the dpkg package manager. It is a command-line tool and no graphical interface is available.

The APT package manager facilitates installing software, removing packages, upgrading the system, searching for a specific package, etc.

This tool is the default package manager for the Debian family. Usually, the Operating systems like Linux Mint and Ubuntu are using the APT package manager.

DNF

The DNF package manager is introduced in Fedora 18. It replaced the widely used YUM. Then Fedora started to use DNF as its default package manager from version 22 on. It is still maturing and yet to support debugging, excluding packages, and skipping broken packages during the installation.

It supports basic operations such as software package installing, updating existing software, downgrading, and uninstalling. At the same time, it provides dependency resolution, good documentation, support for extensions other than python, and many more that were not available in YUM.

This has been very popular among Fedora users. But it can be used within most of the Red hat based distributions such as CentOS Stream, and RedHat.

YUM

YUM is an open-source package manager that comes with both the command-line tool and graphical user interface. The name YUM stands for Yellowdog updater modified.

It is capable of install, remove, search and update RPM packages. It is very similar to the APT package manager.

This is available to use mostly on RPM-based distributions.

RPM

The RPM stands for Red hat Package Manager. It is the core package management system for Red hat distributions and several front-end tools are available for ease of use.

Since this is a very low-level package management system, it supports configuration, installation, query, and removal software packages. This is very much identical to the DPKG of Debian.

We can see the RPM in CentOS Stream and RHEL. It can only manage the Fedora-based software packages.

Pacman

Pacman is an easy-to-use package manager that relieves the burden of managing packages from official repositories or custom builds. This utility program is written in C language.

The basic commands like install, remove a package, upgrade, and dependency resolution are supported. Pacman uses a client-server model which synchronizes the system and keeps it up to date.

Arch Linux is primarily using packman as its default package manager.

Snap

Snap (snappy) is a software deployment and package management system for Ubuntu and other Linux distributions. It was introduced by Canonical in version Ubuntu 16.04 LTS. Snaps are a universal Linux packaging system that has a centralized store for all distributions.

Snap software are self-contained packages with all dependent libraries included that make installation much simpler. As packages are containerized, applications are isolated and any changes won't affect other systems.

The packages are called 'snaps', you can discover, install, and manage packages from snap store.

Unlike apt and yum package, snap packages are updated automatically.  When using snap, you always install a new version of the program.

Flatpak

The Flatpak is a universal package management system. Hence, you can use it in any of the Linux distributions without worrying about the underlying distribution, dependencies or runtime environment.

It supports basic operations such as installing and managing packages. Most importantly, it doesn't depend on Linux distribution.

Flatpak is popular with Fedora and installed by default. For other Distros such as Ubuntu, AlmaLinux, Rocky Linux and Arch Linux is available through the official repository.

From Flathub you search and find hundreds of apps that can be installed on your Linux Distribution.

Zypper

The Zypper is a terminal-based package manager. It is based on the libzyapp library.

There are numerous operations are supported by Zypper. It incorporates basic APT commands and can handle repository extensions.

OpenSUSE Linux uses the Zypper as its main package manager.

Synaptic

Synaptic is one of the GUI-based replacements for the APT package manager. If you are a fan of a gui application then this might be the best for you.

Since this package manager is based on APT, it supports almost all the operations that APT provides such as installation, removal, and update of packages.

It has been used in Debian-based Linux distributions such as Ubuntu and Linux Mint.

dpkg

The DPKG is the core package management system for Debian Linux package managers. This is a very low-level utility program and has no support for automatic dependency resolution.

It is being used to install, list down the installed packages, view the content of a package, display the DPKG license and version number, check the installed location, etc. The primary front-end package manager for the DPKG is Aptitude. It can build .deb packages.

This package manager has been used in the Debian-based systems. it is used inside the derivatives of the Debian family such as Linux-mint, Ubuntu, etc.

Package manager used for?

We have seen several package managers available for different Linux distributions. Usually, a Linux package manager interacts with the relevant software package repository on behalf of the end-user.

Software repositories consist of a metadata file where all the package names, versions, repository details, and package descriptions are stored. Upon the user executes a package manager command, it will first look into the remote repository’s metadata file. Then the package manager creates its version of the metadata in the local machine cache as shown in the following.

When you execute the apt update command for the apt package manager, it will retrieve all the latest version information from the remote repository and update the metadata in the local cache.

The same happens when the end-users install packages from repositories. The package manager looks for the local cache and finds the software package. Then it will use the metadata to find the remote repository URL and connect. It takes care of all the dependencies. It will automatically download all the dependent software packages and install them in advance.

Usually, a package manager can be used to install, upgrade, remove and configure a specific software package. The mentioned jobs can be initiated using the command line tool by entering package manager commands. It is very efficient and faster than ordinary software installation wizards. Most package managers support software package installing upgrading configuring.

Install a new Software

Usually, the software installation process involves finding the vendor executable and going through wizards. It consumes considerable time and effort. The evolution of Linux package managers made it real fast and less effort. It is one command away from installing your software program. In some cases, certain packages need to have dependencies installed. With these package managers, you do not need to worry about the software dependencies or manual configurations.

Let’s use the APT package manager to install a VLC media player in Ubuntu.

Syntax

sudo apt install <package name> <package name> ....

You can use the above command to install multiple packages at once. The SUDO phrase denotes that you are running this as the root user. It is possible to use apt-get command too. It is recommended to use apt over apt-get command.

sudo apt install vlc

The command will search for the repository for the VLC package, download locally and install it with necessary dependencies. The command line tools can be used to check the output.

installing vlc using package manager apt

Upgrade Software to newer version

As mentioned earlier, software packages are installed from the respective Linux distribution repository and other third-party repositories. These repositories contain up-to-date versions of each software package. Hence, you might need to upgrade your local software versions whenever the new update is available. 

There are two commands that need to be executed to upgrade your local software packages. First, we need to retrieve all the latest versions and dependencies for each package from the software repository. The apt update command can be used.

sudo apt update
update package index using the package manager

This command will not install or upgrade the software packages. Hence, we need to run the apt upgrade command to upgrade the packages to newer versions. Before that, we can check which packages are allowed to upgrade as shown in the following. This is not a mandatory step.

apt list --upgradable
list packages available to install and upgrade
sudo apt upgrade
upgrade the packages

That command will show you all the packages that are going to be upgraded. It shows the size of the installation and prompts for the user’s confirmation.

Remove Software

In some cases, you need to uninstall a specific software package because it is no longer needed. The apt remove command can be used to remove packages. The below command will remove a single package named package_name.

sudo apt remove <package_name>

If you need to remove all the dependencies and the configuration file at the same time, you can pass the purge flag to the remove command. This is a very powerful and clean way to remove unused packages.

sudo apt remove <package_name>  --purge

Let’s remove the previously installed VLC media player package and its dependencies from our system.

sudo apt remove vlc --purge
remove package using apt

Search for a Package

In some cases, you might not be sure about the availability of a software package. Hence, the apt package manager offers a way to check the availability of a package using the apt search command. You do not need root access to run this command.

apt search <package_name>

Let’s search for the Zoom software package availability.

apt search zoom
apt search "#1 video conferencing"
Search for a package

This will list down all the package names that match the phrase “Zoom” as shown in the following. You can provide the description of a specific software package to perform the search too.

Conclusion

Linux-based operating systems use their way of managing software applications. The software components have been archived in a specific format. Those are named software packages. Software packages are stored in repositories. The package managers are capable of talking to these repositories. Several package managers are available for different Linux distributions such as apt, dpkg, APM, snap, etc. Most Linux users are familiar with one or two package managers mentioned. Package managers take care of software installation, removal, configuration, and upgrade. There are base package management systems are available to use when needed such as Debian Package management system, Red hat package manager.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment