Getty Images/iStockphoto

Tip

How to use Linux package managers

There are many different package managers for Linux distributions. Linux admins should know what to expect from these distributions and how to tackle software maintenance.

Package managers are essential tools for Linux users. Some familiarity with each package manager is useful because most Linux administrators regularly encounter a variety of distributions.

Package managers report information about software packages, including source, installation date, descriptions, dependencies and more. Package managers help Linux users and administrators install, update and remove applications quickly. Their commands are typically intuitive (e.g., apt install apache2 installs the Apache web server), and most have graphical versions.

You must understand and work with the package manager your distribution prefers. The three most common choices are Dandified Yum (DNF), Advanced Package Tool (APT) and Zypper. DNF works with Red Hat Enterprise Linux (RHEL), Fedora, AlmaLinux and Rocky. APT is for Debian, Ubuntu and Linux Mint, and you can use Zypper with OpenSUSE and SUSE Linux Enterprise Server. But you might also come across Flatpak, Snap, Pacman, Portage and others.

Why are there so many package managers?

Linux offers a wide variety of software package managers compared to the relatively homogeneous macOS and Windows ecosystems. There are a few reasons why there are so many options when they all do similar things.

Some package managers were created before broad Linux standards existed and are now embedded into the distribution, so making a switch would be impractical. Different distributions also have different design philosophies and requirements, necessitating specific software management features. Plus, in the Linux world, there's a lack of any universal software management standard.

Handling dependencies is a key component of modern package managers. When you attempt to install a package, the package manager checks whether any required applications are missing from the system. It can automatically add these dependencies to the overall install process you initiated.

Common package managers

The two most common package managers are RPM Package Manager and APT-based tools. You will need to learn one of these utilities if you work with RHEL, Fedora, Ubuntu, Mint or Debian. You will use different package managers if you select OpenSUSE, Gentoo, Arch or other distributions.

You will most likely need root or delegated privileges to use your system's package manager. The sudo command allows you to execute delegated privileges without full root authority.

The following example will use the Vim text editor though its actual name may vary depending on the package manager.

RPM

RPM uses several different utilities to manage software, including YUM and DNF. This software has the RPM file extension.

Each package manager has its own set of commands, though they are all similar:

  • DNF uses the dnf command with a series of subcommands.
  • YUM uses the yum command and various subcommands.
  • RPM uses the rpm command with more traditional Linux command line flags, such as -i or -e.

Common distributions that use RPM-based package managers include RHEL, Fedora Linux, Rocky Linux and AlmaLinux. There are several common dnf commands:

  • dnf update updates installed packages.
  • dnf install vim installs the specified package.
  • dnf update vim updates all installed packages to their latest version.
  • dnf remove vim removes the specified package.
  • dnf info vim displays detailed package information, including version.

Zypper

SUSE Linux-based distributions use the Zypper package manager. It relies on the standard RPM package format but does not use the rpm, yum or dnf commands. Zypper runs from the command line and is integrated into SUSE's YaST graphical administration tool.

Common distributions using Zypper include openSUSE and SUSE Linux Enterprise Server. There are several common Zypper commands:

  • zypper install vim installs the specified package.
  • zypper remove vim removes the specified package.
  • zypper update updates all installed packages to their latest version.
  • zypper info vim displays detailed package information, including version.

APT

The APT manages software on Debian-derived Linux distributions such as application installation, updates and removal. Software packaged for APT has the .deb file extension. The primary APT command is apt, followed by one or more subcommands.

Common distros that rely on APT include Debian Linux, Ubuntu Linux and Linux Mint. There are several common apt software management commands:

  • apt update refreshes package lists from repositories.
  • apt upgrade updates all installed packages to their latest version.
  • apt install vim installs the specified package.
  • apt remove vim removes the specified package.
  • apt show vim displays detailed package information, including version.

Flatpak

Flatpak runs each application in an isolated sandbox environment, and it offers centralization and isolated dependencies. This method protects the system and other programs from malware. It is distribution-agnostic and offers a centralized way of managing software across multiple Linux distros.

Install Flatpak on your system and direct it to the Flatpak repository. Use the apt install flatpack command to install Flatpak on a Debian-based distribution.

Once you install Flatpak and configure the repository, manage software using the flatpak command.

There are several common flatpak commands:

  • flatpak install vim installs the specified application.
  • flatpak uninstall vim removes the specified application.

Recent versions of Flatpak will search the repository by application name using flatpack install {application}. You must specify the source with the install subcommand on older versions.

Update installed Flatpak applications by using the update subcommand flatpak update.

Display all installed Flatpak applications by using the list subcommand flatpak list.

Snap

The Snap software tool (snapd) provides isolated software environments designed to keep the system and applications secure and easy to maintain. It manages dependencies, libraries and other supporting software on a per-application basis to avoid conflicts.

Install Snap on your Linux distribution using the apt install snapd command. Substitute the dnf command for Red Hat-oriented distros.

Modern versions of Ubuntu usually have snapd installed. Common Snap subcommands include the following:

  • snap install vim installs the specified application.
  • snap remove vim removes the specified application.

Use the snap find {application} command to search the Snap Store from the command line for specific applications.

Pacman

The Arch Linux distribution caters to more experienced users who wish to learn more about the inner workings of a Linux system.

Arch's package manager is Pacman, and it matches the distribution's rolling release schedule to keep the system current. Pacman is a fast and efficient package manager when you compare it to APT and DNF.

The Manjaro and Endeavor Linux distributions are based on Arch Linux, as is BlackArch, a well-known penetration testing platform.

Pacman uses flags rather than descriptive words. Whereas DNF has a dnf install command, Pacman uses pacman -S to deploy software. There are several common Pacman commands:

  • pacman -Syy refreshes package list from repositories.
  • pacman -Syu updates all installed packages to their latest version.
  • pacman -S vim installs the specified application.
  • pacman -Rs vim removes the specified application and its dependencies.
  • pacman -Si vim displays detailed package information, including version.

Portage

The Gentoo Linux distribution follows a rolling release schedule and emphasizes granular control over your system. Gentoo might be intimidating for newer Linux users who must compile the OS from source code as part of the installation process. Compiling the OS allows you to control all aspects of your deployment.

Gentoo's package manager is Portage. Like the operating system, Gentoo software is compiled during installation which offers users control and customization. This approach differs significantly from pre-compiled packages like those used with DNF or APT.

The primary Portage command to install, update and uninstall applications is emerge. There are several Portage software management commands:

  • emerge vim installs the specified application.
  • emerge -auDN @world updates all installed packages to their latest version.
  • emerge -C vim removes the specified application.
  • emaint helps with maintenance tasks.
  • emaint -a sync refreshes package list from repositories.
  • equery gathers software information.
  • equery list vim displays detailed package information, including version.

Updating software and other maintenance tasks

Software maintenance is critical to a sysadmin's job. Package managers help you understand what software version is installed and whether it needs to be updated.

Package managers make software updates and version control easier. Commands like dnf update httpd or apt upgrade apache2 let Linux users maintain the latest versions on their systems.

Repositories, or repos, are another way that package managers help control software. Software repos are designated storage areas that package managers check when they install or update software.

Most distributions point to the vendor's own repositories, but you can configure any repos. One common approach is to point the package manager only at a repository managed in-house, with careful control of available software versions. This control helps prevent version drift and unplanned updates.

Damon Garn owns Cogspinner Coaction and provides freelance IT writing and editing services. He has written multiple CompTIA study guides, including the Linux+, Cloud Essentials+ and Server+ guides, and contributes extensively to TechTarget Editorial and CompTIA Blogs.

Dig Deeper on Systems automation and orchestration

Software Quality
App Architecture
Cloud Computing
SearchAWS
TheServerSide.com
Data Center
Close