Arch Linux Package Management - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
Arch Linux Package Management Guide
Complete beginner-friendly guide to managing packages on Arch Linux using pacman, AUR helpers, and package repositories.
Table of Contents
- Understanding Package Management
- Pacman Basics
- Installing Packages
- Removing Packages
- Updating System
- Searching Packages
- Package Information
- Arch User Repository (AUR)
- AUR Helpers
- Mirrors Configuration
- Troubleshooting
Understanding Package Management
What is Package Management?
Package management is installing, updating, and removing software.
In Arch Linux:
- Official packages: Managed by
pacman - AUR packages: Community-maintained packages
- Binary packages: Pre-compiled software
- Source packages: Compiled from source
Package Formats
Arch Linux uses:
.pkg.tar.zst: Compressed package archive- PKGBUILD: Build script for AUR packages
- Repository: Collection of packages
Pacman Basics
What is Pacman?
pacman is Arch Linux's package manager.
Current version (2025):
- Pacman 7.1: Latest version with security enhancements
- Improved package verification
- Better dependency resolution
- Enhanced security features
Features:
- Install/remove packages
- Update system
- Search packages
- Resolve dependencies
- Manage repositories
Basic Syntax
General format:
pacman [options] [package(s)]
Common options:
-S: Sync (install/update)-R: Remove-U: Upgrade (from file)-Q: Query (local database)-Syu: Sync, update, upgrade
Installing Packages
Install Single Package
Basic installation:
# Install a package
sudo pacman -S package-name
# Example: Install Firefox
sudo pacman -S firefox
What happens:
- Downloads package
- Resolves dependencies
- Installs package
- Updates package database
Install Multiple Packages
Install several packages:
# Install multiple packages
sudo pacman -S package1 package2 package3
# Example
sudo pacman -S firefox vim git
Install from Group
Install package groups:
# List groups
pacman -Sg
# Install group
sudo pacman -S gnome
# Install specific package from group
sudo pacman -S gnome-extra
Explanation:
-Sg: Lists package groups- Groups contain related packages
- Can install entire group or specific packages
Install with Confirmation
Review before installing:
# Show package info before install
sudo pacman -Si package-name
# Install with confirmation
sudo pacman -S package-name
# Press 'y' to confirm
Removing Packages
Remove Package
Basic removal:
# Remove package
sudo pacman -R package-name
# Example: Remove Firefox
sudo pacman -R firefox
Remove with Dependencies
Remove package and unused dependencies:
# Remove package and unused deps
sudo pacman -Rs package-name
# Remove package, deps, and config files
sudo pacman -Rns package-name
Explanation:
-R: Remove package only-Rs: Remove package and unused dependencies-Rns: Remove package, deps, and config files
Remove Orphans
Remove unused packages:
# List orphan packages
pacman -Qdt
# Remove orphan packages
sudo pacman -Rns $(pacman -Qdtq)
Explanation:
-Qdt: Lists orphan packages (installed as deps, no longer needed)-Rns: Removes packages$(...): Command substitution
Updating System
Update Package Database
Refresh package lists:
# Update package database
# Update database and upgrade (recommended)
sudo pacman -Syu
# Note: Using -Sy without -u can cause dependency issues
# Always use -Syu for updates
Important Note:
- Always use
-Syutogether - Using-Sywithout-ucan cause dependency issues -Syu: Sync database AND upgrade packages (recommended)- Only use
-Sywhen specifically needed (e.g., checking package availability)
Upgrade System
Update all packages:
# Update system
sudo pacman -Syu
# Update and refresh
sudo pacman -Syuu
Explanation:
-Syu: Sync, update, upgrade-Syuu: Also downgrades if needed- Updates all installed packages
Check for Updates
See what would be updated:
# Check updates
pacman -Qu
# Check updates with details
pacman -Qu --print-format "%n %v -> %v"
Expected output:
firefox 120.0 -> 121.0
linux 6.6.0 -> 6.7.0
Searching Packages
Search Official Repositories
Search for packages:
# Search packages
pacman -Ss search-term
# Example: Search for text editor
pacman -Ss editor
Expected output:
extra/vim 9.0.0000-1
Vi IMproved - enhanced vi editor
extra/nano 7.2-1
Pico clone with enhancements
Explanation:
-Ss: Search sync database (repositories)- Shows package name, version, description
Search Installed Packages
Search locally installed:
# Search installed packages
pacman -Qs search-term
# Example
pacman -Qs firefox
Expected output:
local/firefox 121.0-1
Standalone web browser from mozilla.org
Explanation:
-Qs: Query (search) local database- Shows only installed packages
Package Information
Package Details
Get package information:
# Info about package in repository
pacman -Si package-name
# Info about installed package
pacman -Qi package-name
Shows:
- Name, version, description
- Dependencies
- Installation size
- Repository
List Installed Packages
List all installed packages:
# List all installed
pacman -Q
# List with version
pacman -Q | grep package-name
# List explicitly installed
pacman -Qe
# List as dependencies
pacman -Qd
Explanation:
-Q: Query (list) installed packages-Qe: Explicitly installed (not as dependency)-Qd: Installed as dependency
Package Files
List files in package:
# List files in installed package
pacman -Ql package-name
# Find which package owns file
pacman -Qo /path/to/file
Example:
# Find package owning /usr/bin/firefox
pacman -Qo /usr/bin/firefox
Arch User Repository (AUR)
What is AUR?
AUR (Arch User Repository) is community-maintained packages.
Features:
- Community packages
- Not in official repos
- Built from source
- User-contributed
AUR Website
Browse AUR:
- Website: https://aur.archlinux.org/
- Search packages
- View PKGBUILDs
- Check package info
Installing from AUR
Manual installation:
# Clone AUR package
git clone https://aur.archlinux.org/package-name.git
cd package-name
# Review PKGBUILD
cat PKGBUILD
# Build and install
makepkg -si
Explanation:
git clone: Downloads package sourcePKGBUILD: Build scriptmakepkg -si: Builds and installs package-s: Install dependencies-i: Install package
AUR Package Structure
What's in AUR package:
package-name/
├── PKGBUILD # Build script
├── .SRCINFO # Package metadata
└── other files # Patches, etc.
AUR Helpers
What are AUR Helpers?
AUR helpers automate AUR package installation.
Popular helpers:
- yay: Yet Another Yaourt (recommended)
- paru: Fast AUR helper
- pamac: GUI package manager
- aurman: Advanced AUR helper
Installing yay
Install yay:
# Clone yay
git clone https://aur.archlinux.org/yay.git
cd yay
# Build and install
makepkg -si
Using yay
Basic usage:
# Search AUR
yay search-term
# Install from AUR
yay -S package-name
# Update AUR packages
yay -Sua
# Update everything
yay -Syu
Explanation:
yay: Search AUR packages-S: Install package-Sua: Update AUR packages only-Syu: Update everything (official + AUR)
Installing paru
Install paru:
# Clone paru
git clone https://aur.archlinux.org/paru.git
cd paru
# Build and install
makepkg -si
Using paru
Basic usage:
# Search AUR
paru search-term
# Install from AUR
paru -S package-name
# Update AUR packages
paru -Sua
Mirrors Configuration
What are Mirrors?
Mirrors are servers hosting Arch packages.
Why configure:
- Faster downloads
- Geographic proximity
- Reliability
Configure Mirrors
Edit mirror list:
# Edit mirror list
sudo vim /etc/pacman.d/mirrorlist
# Or use reflector (recommended)
sudo pacman -S reflector
Using Reflector
Generate optimal mirrors:
# Generate top 10 mirrors
sudo reflector --country "United States" --latest 10 --sort rate --save /etc/pacman.d/mirrorlist
# Update and save
sudo reflector --latest 20 --sort rate --save /etc/pacman.d/mirrorlist
Explanation:
--country: Filter by country--latest: Number of mirrors--sort rate: Sort by download speed--save: Save to mirrorlist
Manual Mirror Selection
Edit mirrorlist:
sudo vim /etc/pacman.d/mirrorlist
Uncomment preferred mirrors:
## United States
Server = http://mirror.example.com/archlinux/$repo/os/$arch
Order matters - pacman tries mirrors in order.
Troubleshooting
Common Issues
Package conflicts:
# Check for conflicts
pacman -Qkk
# Fix package database
sudo pacman -Syu --overwrite "*"
Broken dependencies:
# Check broken packages
pacman -Qkk
# Reinstall package
sudo pacman -S package-name --overwrite "*"
Lock file error:
# Remove lock file
sudo rm /var/lib/pacman/db.lck
Explanation:
- Lock file prevents concurrent pacman operations
- Remove if pacman was interrupted
Package Cache
Clean package cache:
# List cache size
du -sh /var/cache/pacman/pkg
# Clean old packages
sudo pacman -Sc
# Clean all packages
sudo pacman -Scc
Explanation:
-Sc: Remove old package versions-Scc: Remove all cached packages
Summary
This guide covered:
- Pacman basics - Package manager commands
- Installing packages - Single and multiple
- Removing packages - With dependencies
- Updating system - System updates
- Searching packages - Find software
- Package information - Details and files
- AUR - Community repository
- AUR helpers - yay, paru
- Mirrors - Faster downloads
- Troubleshooting - Common issues
Key Takeaways:
pacman -Sinstalls packagespacman -Syuupdates system- AUR provides community packages
- Use AUR helpers for convenience
- Configure mirrors for speed
Next Steps
- Arch Linux System Configuration - System setup
- Arch Linux Post-Installation - Essential steps
- Arch Linux Repository Configuration - Repository setup
- ArchWiki Pacman: https://wiki.archlinux.org/title/Pacman
- ArchWiki AUR: https://wiki.archlinux.org/title/Arch_User_Repository
This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki.