DEV Community

Cover image for Learn Package Management on Arch Linux: pacman & yay
Ishan Jarwal
Ishan Jarwal

Posted on

Learn Package Management on Arch Linux: pacman & yay

Part 1: Understanding pacman

pacman is the default package manager for Arch Linux. It directly interacts with the official repositories and handles installation, updates, and removal of software.

Basic Syntax

sudo pacman [options] [package_name]
Enter fullscreen mode Exit fullscreen mode

Common pacman Commands

Task Command Description
Update package database and system sudo pacman -Syu Sync package list (-Sy) and upgrade all packages (-u).
Install a package sudo pacman -S <package> Installs package from official repo.
Remove a package sudo pacman -R <package> Removes a package (keeps dependencies).
Remove a package and its unused dependencies sudo pacman -Rns <package> Clean uninstall — removes package, configs, and dependencies.
Search for a package pacman -Ss <keyword> Search available packages.
List installed packages pacman -Q Shows all installed packages.
Show package info pacman -Qi <package> Displays metadata (version, size, dependencies).
Clean cache sudo pacman -Sc Removes old packages from cache.

Official Reference:

Pacman Manual - ArchWiki

🧹 Pro Tip

To free up space, remove unused dependencies and old cached packages:

sudo pacman -Rns $(pacman -Qdtq)
sudo pacman -Scc
Enter fullscreen mode Exit fullscreen mode

Part 2: Using yay for AUR Packages

The Arch User Repository (AUR) contains community-maintained build scripts (PKGBUILDs) for software not in the official repositories.

yay (Yet Another Yaourt) is a lightweight, fast, and user-friendly AUR helper that automates the build and installation process.

Basic Syntax

yay [options] [package_name]
Enter fullscreen mode Exit fullscreen mode

Common yay Commands

Task Command Description
Update everything (official + AUR) yay -Syu Sync and upgrade both official and AUR packages.
Install an AUR package yay -S <package> Automatically fetches, builds, and installs from AUR.
Search for AUR packages yay -Ss <keyword> Search both official and AUR repositories.
Remove a package yay -Rns <package> Same as pacman — removes package + unused dependencies.
Clean build cache yay -Sc Clean yay’s build directory.
List all AUR packages yay -Qm Shows all manually installed (AUR) packages.
Check for outdated AUR packages yay -Qua Lists AUR updates available.

💡 Tip: Unlike pacman, yay doesn’t need sudo for most operations until the build process actually installs system files — it will prompt automatically.

Official Reference:

Yay GitHub Repository

Flag Summary

Flag Tool Meaning
-S pacman/yay Install package(s)
-R pacman/yay Remove package(s)
-Ss pacman/yay Search package in repos
-Qi pacman Show package info
-Qm yay List manually installed (AUR) packages
-Syu pacman/yay Sync database and upgrade all packages
-Rns pacman/yay Remove package + dependencies + configs
-Sc pacman/yay Clean package cache
-Qdtq pacman List orphaned packages

Further Reading:

Top comments (0)