Learning Objectives:
- Master pacman package manager commands for installation, updates, and maintenance
- Understand and safely use the Arch User Repository (AUR) with helper tools
- Implement proper system update strategies for rolling release maintenance
- Develop troubleshooting skills for package conflicts and dependency issues
Pacman is Arch Linux's powerful package manager, designed for simplicity and efficiency. Unlike package managers that require separate commands for different operations, pacman uses a unified interface with intuitive flags.
Essential Pacman Commands: Master these fundamental operations for daily package management:
Package Installation:
# Install single package
sudo pacman -S package-name
# Install multiple packages
sudo pacman -S package1 package2 package3
# Install with dependency confirmation
sudo pacman -S --needed package-name
The --needed
flag prevents reinstallation of already-installed packages, useful in scripts and batch operations.
Package Removal:
# Remove package only
sudo pacman -R package-name
# Remove package and unused dependencies
sudo pacman -Rs package-name
# Remove package, dependencies, and configuration files
sudo pacman -Rns package-name
The -Rs
combination is most commonly used as it cleans up orphaned dependencies, preventing system bloat.
System Updates:
# Update package database
sudo pacman -Sy
# Update all packages
sudo pacman -Su
# Update database and packages (recommended)
sudo pacman -Syu
# Force database refresh and update
sudo pacman -Syyu
Never use pacman -Sy package-name
as this can create partial upgrades leading to system instability. Always use -Syu
for updates.
Package Queries and Information:
# Search for packages
pacman -Ss search-term
# List installed packages
pacman -Q
# Show package information
pacman -Si package-name
# Show installed package info
pacman -Qi package-name
# List package files
pacman -Ql package-name
# Find which package owns a file
pacman -Qo /path/to/file
Advanced Pacman Operations: Handle complex package management scenarios:
Dependency Management:
# List orphaned packages
pacman -Qdt
# Remove all orphaned packages
sudo pacman -Rns $(pacman -Qtdq)
# List packages installed as dependencies
pacman -Qd
# Mark package as explicitly installed
sudo pacman -D --asexplicit package-name
Package Cache Management: Pacman stores downloaded packages in /var/cache/pacman/pkg/
. Manage this cache to save disk space:
# Clean cache of uninstalled packages
sudo pacman -Sc
# Clean entire cache (use with caution)
sudo pacman -Scc
# Install paccache for automated cleaning
sudo pacman -S pacman-contrib
sudo paccache -r # Keep 3 most recent versions
The Arch User Repository is a community-driven repository containing user-submitted packages. Unlike official repositories, AUR packages are built from source on your system, providing access to software not available in official repos.
Understanding AUR Packages: AUR packages come as PKGBUILD files that contain instructions for building packages from source. This approach offers several advantages:
- Access to cutting-edge software versions
- Packages for niche or specialized software
- Git versions of development software
- Proprietary software with automated installation
Manual AUR Installation Process: Understanding the manual process helps you troubleshoot AUR helpers and builds trust in the packages you install:
# Clone AUR package repository
git clone https://aur.archlinux.org/package-name.git
cd package-name
# Review PKGBUILD file (IMPORTANT for security)
cat PKGBUILD
# Build and install package
makepkg -si
The -s
flag installs dependencies, and -i
installs the built package. Always review PKGBUILD files before building, as they execute arbitrary code during compilation.
AUR Helpers: AUR helpers automate the manual process while providing additional features. The two most popular modern helpers are yay and paru.
Installing and Using Yay:
# Install yay (one-time setup)
sudo pacman -S --needed base-devel git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
# Use yay for AUR packages
yay -S aur-package-name
# Update system including AUR packages
yay -Syu
# Search both official and AUR repositories
yay -Ss search-term
Installing and Using Paru (written in Rust, faster than yay):
# Install paru
yay -S paru
# Use paru (same syntax as yay)
paru -S aur-package-name
paru -Syu
AUR Safety Best Practices: The AUR's flexibility comes with security responsibilities:
- Always review PKGBUILDs before installation
- Check package popularity and votes on the AUR website
- Verify maintainer reputation and update frequency
- Use official repositories when possible - only use AUR when necessary
- Keep AUR packages updated to receive security fixes
Arch Linux's rolling release model requires disciplined update practices to maintain system stability and security.
Update Strategy and Timing: Develop a consistent update routine:
Daily Updates (for experienced users):
# Quick update check
checkupdates
# Full system update
sudo pacman -Syu
Weekly Updates (recommended for most users):
# Update with AUR helper
yay -Syu
# Check for news and breaking changes
curl -s https://archlinux.org/feeds/news/ | head -20
Before Major Updates: Always check Arch Linux news for breaking changes or manual interventions required.
Handling Update Conflicts: When updates fail or create conflicts:
Package Conflicts:
# Force database refresh
sudo pacman -Syyu
# Resolve file conflicts
sudo pacman -S --overwrite glob-pattern package-name
# Remove conflicting packages
sudo pacman -Rdd conflicting-package
Dependency Issues:
# Check broken dependencies
pacman -Qk
# Reinstall package with dependencies
sudo pacman -S --needed package-name
# Force dependency resolution
sudo pacman -Sdd package-name
System Recovery: When updates break the system:
# Boot from Arch ISO and chroot
mount /dev/sdX2 /mnt
arch-chroot /mnt
# Downgrade problematic packages
sudo pacman -U /var/cache/pacman/pkg/package-old-version.pkg.tar.xz
# Use downgrade tool for easier downgrades
yay -S downgrade
sudo downgrade package-name
Package Database Maintenance: Keep your package database healthy:
# Check database integrity
sudo pacman -Dk
# Rebuild package database
sudo pacman-db-upgrade
# Verify package files
sudo pacman -Qkk
Command Practice: Create a cheat sheet of essential pacman commands and practice each one. Install and remove test packages to build muscle memory.
AUR Exploration: Install an AUR helper (yay or paru) and practice installing a simple AUR package. Always review the PKGBUILD file before building.
Update Routine: Establish a regular update schedule and practice checking Arch news before major updates. Set up a system for monitoring breaking changes.
Conflict Resolution: Intentionally create a package conflict in a virtual machine and practice resolving it using various pacman techniques.
Cache Management: Set up automated cache cleaning using paccache and monitor your package cache size over time.
You've now mastered Arch Linux's package management ecosystem, from basic pacman operations to advanced AUR usage and system maintenance. This knowledge forms the foundation for maintaining a healthy, up-to-date Arch Linux system.
Understanding pacman's unified command structure and the AUR's community-driven approach gives you access to one of the most comprehensive software ecosystems in Linux. The rolling release model, while requiring more attention than fixed releases, ensures you always have access to the latest software and security updates.
Your package management skills will be essential as we move into the next module, where we'll install and configure desktop environments and graphics systems using the tools and techniques you've just learned.