Package Management
Package managers lie at the heart of modern Linux systems, providing quick and consistent ways to install, update, and remove software. They pull information from local or remote repositories, ensuring you have the latest versions or security patches with minimal friction. Each distro may use its own manager, but the core ideas remain similar across them all.
1. Overview
A package manager is a system or software tool that automates the process of installing, upgrading, configuring, and removing software packages. Each package may contain metadata (dependencies, version info, scripts) that the manager uses to ensure consistency. Repositories (repos) are centralized storage locations—either on the local machine or remote servers—where packages reside. When you run a package manager command, it queries these repos to find the relevant software and dependencies, checking version compatibility along the way.
Different Linux distributions often have their own native manager (Ubuntu uses
apt
; Arch uses pacman
or yay
for AUR;
Fedora uses dnf
; CentOS uses yum
or dnf
;
openSUSE uses zypper
; etc.), though the principle remains the same:
maintain a local list of available packages, resolve dependencies, and handle
software in a consistent manner.
2. APT (Debian/Ubuntu)
The Advanced Package Tool (apt
) is the go-to manager
on Debian, Ubuntu, and related distributions. It uses /etc/apt/sources.list
and /etc/apt/sources.list.d/
to define repository locations.
Command | Description |
---|---|
sudo apt update |
Updates the local package index from defined repos. |
sudo apt upgrade |
Upgrades all installed packages to their latest available versions. |
sudo apt install [package] |
Installs [package] plus any dependencies. |
sudo apt remove [package] |
Removes [package] while leaving config files intact. |
sudo apt purge [package] |
Removes [package] plus config files (where applicable). |
3. Snap Packages
Snap is a universal package format created by Canonical (Ubuntu’s sponsor)
to bundle apps with their dependencies into a single snap file. Snaps are sandboxed,
automatically updated, and can run on various Linux distros if snapd
is installed.
Command | Description |
---|---|
sudo snap find [keyword] |
Searches the Snap Store for packages matching [keyword] . |
sudo snap install [snapname] |
Installs a snap package from the Snap Store. |
sudo snap remove [snapname] |
Removes a previously installed snap package. |
snap list |
Lists all installed snaps on the system, including versions and channels. |
4. Yay (Arch Linux)
Yay (Yet Another Yogurt) is an AUR helper used on Arch-based distributions to search for and install packages from both the official repositories and the Arch User Repository (AUR).
Command | Description |
---|---|
yay -Syyu |
Refreshes repo databases and upgrades all packages (including AUR).
-Syy forces a refresh, -u upgrades installed packages.
|
yay -S [package] |
Installs [package] , searching official repos and AUR.
Prompts if multiple matches are found.
|
yay -Rs [package] |
Removes [package] along with its dependencies if not needed by other packages. |
yay -Ss [keyword] |
Searches both official repos and AUR for [keyword] . |
5. RPM (Fedora/CentOS/OpenSUSE)
rpm
(Red Hat Package Manager) is a low-level tool for installing, querying,
verifying, and removing packages on RPM-based systems (Fedora, CentOS, openSUSE, etc.).
High-level managers like dnf
or yum
wrap rpm
for dependency resolution.
Command | Description |
---|---|
rpm -ivh [package.rpm] |
Installs the specified RPM with verbose and hash progress.
-i install, -v verbose, -h hash.
|
rpm -Uvh [package.rpm] |
Upgrades if installed, otherwise installs. -U for upgrade. |
rpm -e [package] |
Removes the package by name (not the .rpm file). |
rpm -qa | grep [name] |
Lists installed RPMs, optionally searching for [name] . |
In practice, on Ubuntu you won’t typically use rpm
, but it’s good to
understand how package managers differ across Linux distributions.
6. Conclusion
Whether you use apt
on Ubuntu, snap
for universal packages,
yay
on Arch-based distros, or rpm
on RPM-based systems,
the fundamental goal remains the same: acquire and manage software while respecting
dependencies. Understanding your chosen distro’s package manager ensures you can
install, update, and remove software reliably without breaking your system.
As you explore advanced topics—such as pinning package versions or adding custom
repositories—these foundational commands will keep your environment in order.