DEV Community

Cover image for The Basics of Package Management in Linux
theelvace.eth
theelvace.eth

Posted on

The Basics of Package Management in Linux

In our world today, technologies move at a fast pace. Constant development and deployment provide the end-users with a plethora of options. As a result of these regular launchings, the possibilities of errors occurring are more pronounced. Errors when left unchecked lead to bad code which in turn affects the product’s quality.

This is why it is important to carry out necessary updates and automate real-time checks on the software. Most importantly, these should be done without affecting the performance of the application. DevOps and Cloud Infrastructure Engineers have these unenviable tasks, and where they are not present, the companies use DevOps practices to ensure the release of quality software, while building quality collaboration between their Developers and Operations teams.

To be a well-grounded DevOps Engineer or implement DevOps practices efficiently, it is important to have solid knowledge and experience in the basics. One of these basics is Linux and the management of packages in it.

This article will show you what package management in Linux is, how you can get started in it, the different package management systems and their benefits, and some core concepts and commands to help you install and work around these package managers.


The most common tasks a sysadmin has to take care of are installing, patching, and removing software packages on Linux machines. This is because, on Linux, the software is generally built as packages which are then distributed through repositories (repos) before entering the management phase on the end-user’s system through package managers.

Package Management

The method of using specific repositories to install, update, remove, and track software updates in the Linux system is known as Package Management. Every Linux system contains thousands of packages, of which many are required dependencies for other packages.

A package manager is a software in a Linux system that provides a consistent and automated process of installing, upgrading, configuring, and removing packages from the operating system.

Operating systems (OS) depend on software applications to carry out tasks that solve problems for the user. When software and operating systems were still early and weren’t that popular, applications were developed and tested for bugs before they were released. This was done to provide a good user experience. Not any longer. Now, applications are released to apply bug fixes in newer versions. These newer versions are accessed with the use of updaters or by the user obtaining an upgraded release of the software.

Linux however has adopted a timely software management practice where they create packaging formats, unique tools for installation, and software packages. To achieve these, Linux distributions (distros) use different package management tools. In the rest of this article, we will talk about package installation tools like Tarball and package management tools like DEB and RPM, and YUM.

Tarball

In adding software to early Linux systems, the user was required to download the source code of the software and compile it in binary files, before adding them to the system. The software is made available by users in a compiled form that is known as the tarball (Tar). A tarball typically contains multiple files ranging from configuration files to documentation, to executables, and libraries. All of these files are compressed into a single file for ease of storage and distribution.

Image description

Short for “tape archive,” Tar is especially useful for testing and development of software and it supports most Linux distributions like Ubuntu, CentOS, and Amazon Linux 2. While the creation of tarball may seem easy, the process of installing it isn’t as easy. For example, because tarball package installation spreads the files connected to the software being installed across the system, it’s not an easy task locating the package documentation and configuration files even if the user knows the commands.

This makes it difficult to locate files to uninstall software. Tracking bugs and getting newer versions of software also becomes difficult because of the absence of Metadata in tarballs which confuses the version details after installation. To solve these problems, software packaging in Linux distributions grew into two formats:

  • Debian-based Linux distributions
  • RPM Packaging

Debian-based Packaging (DEB)

Image description

This is the software package used by Debian Linux distributions. All relevant files with metadata in a .ar archive format are included in the .deb files. The metadata here contains relevant details of the software like the version, licenses, description, dependencies, etc. Debian distributions are popular for offering both graphical interfaces and terminal-based tools for managing .deb files.

Some of these tools include:

  • dpkg

This allows the user to set up, remove, manipulate, and upgrade software easily. The dpkg downloads DEB package content to the system and sends notifications about the essential dependencies. You can install a .deb file using dpkg with the command below.

sudo dpkg -i <package name>.deb
Enter fullscreen mode Exit fullscreen mode
  • Apt

This is an Ubuntu advanced package manager that uses an apt-get command to search and manage package installation. You can install a package from the repository using the apt-get command.

sudo apt-get install -s <package name>
Enter fullscreen mode Exit fullscreen mode
  • Aptitude

This is a package management tool that provides a text-based interface to run in the terminal. Because Aptitude doesn’t come pre-installed in all Linux distros, you will have to install it with the following command:

sudo apt-get install aptitude
Enter fullscreen mode Exit fullscreen mode

Once Aptitude is installed, to install a package, issue the following command:

aptitude install <package name>
Enter fullscreen mode Exit fullscreen mode
  • Ubuntu Software Centre

This is an intuitive graphical user interface that users who are new to Linux can use in searching and installing packages.

RPM Packaging

Originally called Red Hat Package Manager, the RPM Package Manager is an open-source program for installing, uninstalling, and managing software packages in Linux. It is used in CentOS, Red Hat, Fedora, OpenSUSE, OpenMandriva, and RHEL-based Linux distributions. The RPM Package Manager combines binaries and available files that are required via upstream software providers to create an RPM package. With the aid of signatures, users can verify the validity of packages before they are added to a repository. With this done, users can access the verified packages from the repositories that are placed inside the CDs or directories through FTP/NFS servers.

Image description

How to use RPM

To use RPM commands you first need to gain sudo permission and you’ll probably need to have a package you want to install already.

Install RPM Package

To install a file using RPM, you can execute the following command:

$ rpm -i [package_file_name].rpm
Enter fullscreen mode Exit fullscreen mode

Uninstall RPM Package

To uninstall a package, you can use the package name instead of the full RPM file name. You can also add more package names. This will help you remove multiple packages in one command.

$ rpm -e [package_name] [another package_name…]
Enter fullscreen mode Exit fullscreen mode

Upgrade

$ rpm -u [package_file_name].rpm
Enter fullscreen mode Exit fullscreen mode

Verify RPM Package

Use the command below to verify an installed RPM package.

$ rpm -Vp sqlbuddy-1.3.3–1.noarch.rpm
Enter fullscreen mode Exit fullscreen mode

Query RPM Package Information (Before Installing)

To see a package’s information before you install it, use

$ rpm -qip [package_name]
Enter fullscreen mode Exit fullscreen mode

Query Package Information (After Installing)

To see the package information after installing, you can use

$ rpm -qi [package_name]
Enter fullscreen mode Exit fullscreen mode

List Documentation of Installed RPM Package

To check the available documentation of an installed RPM package use the command

$ rpm -qdf /usr/bin/[package_name]
Enter fullscreen mode Exit fullscreen mode

There have been some problems with the RPM package. A major one is that it fails in the absence of dependencies. While the DEB-based software packaging could resolve this dependency problem, following the increasing popularity of RPM packages, YUM facilities are resolving the issue better.

Yellowdog Updater Modified (YUM)

Image description

YUM serves as the primary package management tool for installing, updating, and managing software packages in Red Hat Enterprise Linux. YUM is used to manage packages in CentOS/RHEL 7, Fedora 21, and earlier versions of these distributions. It carries out dependency resolution when installing, updating, and removing software packages.

YUM was introduced initially to manage the dependencies of RPM packages. It considers each RPM package as part of a large software repository. YUM provides an interface that is easy to use on top of the functions that are available in the RPM Package Manager. YUM’s main configuration file is at /etc/yum.conf, and the repos are at /etc/yum.repos.d.

There are a lot of commands and options available to use with YUM. Below are a few of them:

  • yum install — To install specified packages
  • update — To update each package
  • remove — This removes specified packages
  • search — To search for keywords
  • repolist — This lists repositories

Conclusion

In this article, you’ve learned what package management is and some package managers there are. Package management is a constant for every system and a task that needs to be carried out. Managers like RPM and YUM provide seamless ways of installing, upgrading, removing, and tracking software packages on RHEL systems.

Resources

You may find the following resources helpful:

Top comments (0)