Introduction to Linux Package Management

By Jennifer Mathew

Updated on May 10, 2024

In this tutorial, we have covered introduction to Linux Package Management. Understanding apt, yum/dnf, and pacman. Package management systems are essential tools for managing software on Linux distributions. 

They streamline the process of installing, updating, and removing software packages, ensuring system stability and security. In this tutorial, we'll explore three popular package management systems: apt (used in Debian/Ubuntu), yum/dnf (found in RHEL/CentOS), and pacman (utilized by Arch Linux).

We'll cover the basics of each system, including package installation, updates, and removal.

1. Understanding Package Management Systems:

  • apt (Advanced Package Tool): Used primarily in Debian-based distributions like Ubuntu, apt simplifies package management by providing a high-level command-line interface. It handles dependencies automatically, making it easy to install, update, and remove software.

  • yum (Yellowdog Updater Modified) and dnf (Dandified yum): Originally developed for Red Hat Linux, yum and its successor, dnf, are package management utilities for RPM-based distributions such as RHEL (Red Hat Enterprise Linux) and CentOS. They automate the process of fetching and installing software packages from repositories.

  • pacman: Designed for Arch Linux and its derivatives, pacman is a powerful package manager that uses a simple command-line interface. It focuses on simplicity, speed, and efficiency, offering robust dependency resolution and package management capabilities.


2. Installing Packages:

apt:

  • To install a package using apt, use the command: sudo apt install package_name.
  • Apt will fetch the package from the configured repositories and install it along with any necessary dependencies.

yum/dnf:

  • Use sudo yum install package_name or sudo dnf install package_name to install a package via yum or dnf, respectively.
  • Yum/dnf will download the package and its dependencies from the enabled repositories and install them.

pacman:

  • To install a package with pacman, run: sudo pacman -S package_name.
  • Pacman will retrieve the package from the official repositories or the Arch User Repository (AUR) and install it.


3. Updating Packages:

apt:

  • Update package information with sudo apt update, then upgrade installed packages using sudo apt upgrade.

yum/dnf:

  • For yum, run sudo yum update to update all installed packages. For dnf, use sudo dnf update.

pacman:

  • Update the package list with sudo pacman -Sy, followed by upgrading packages with sudo pacman -Syu.


Removing Packages:

apt:

  • To remove a package with apt, use sudo apt remove package_name.

yum/dnf:

  • Remove a package using sudo yum remove package_name or sudo dnf remove package_name.

pacman:

  • To uninstall a package, run sudo pacman -R package_name. To remove the package along with its dependencies that are not required by other packages, use sudo pacman -Rs package_name.


Additional Package Management Tasks:

Searching for Packages:

  • Apt: apt search keyword
  • Yum/dnf: yum search keyword or dnf search keyword
  • Pacman: pacman -Ss keyword

Listing Installed Packages:

  • Apt: apt list --installed
  • Yum/dnf: yum list installed or dnf list installed
  • Pacman: pacman -Q

Managing Repositories:

  • Apt: Edit /etc/apt/sources.list or add files to /etc/apt/sources.list.d/.
  • Yum/dnf: Edit .repo files in /etc/yum.repos.d/.
  • Pacman: Edit /etc/pacman.conf or add files to /etc/pacman.d/.


Conclusion:

We have seen introduction to Linux Package management systems like apt, yum/dnf, and pacman are crucial for maintaining Linux systems. Understanding how to install, update, and remove packages using these tools is fundamental for efficient system administration. By mastering these basics, you'll be better equipped to manage software on your chosen Linux distribution.