Arch Linux Pacman Tips Troubleshooting - ryzendew/Linux-Tips-and-Tricks GitHub Wiki

Arch Linux Pacman Tips & Troubleshooting Guide

Complete beginner-friendly guide to pacman tips, tricks, and troubleshooting on Arch Linux, covering common issues, optimization, and advanced techniques.


Table of Contents

  1. Pacman Tips & Tricks
  2. Common Issues
  3. Dependency Problems
  4. Package Conflicts
  5. Performance Optimization
  6. Advanced Troubleshooting
  7. Prevention & Best Practices

Pacman Tips & Tricks

Useful Commands

View package information:

# Show package information
pacman -Qi package-name

# Show package files
pacman -Ql package-name

# Show which package owns a file
pacman -Qo /path/to/file

# Show package dependencies
pacman -Qi package-name | grep Depends

Package Groups

Work with package groups:

# List all groups
pacman -Sg

# List packages in a group
pacman -Sg group-name

# Install entire group
sudo pacman -S group-name

Package History

View package history:

# Show package installation date
pacman -Qi package-name | grep "Install Date"

# Show all installed packages
pacman -Q

# Show explicitly installed packages
pacman -Qe

# Show foreign packages (AUR)
pacman -Qm

Common Issues

Package Not Found

Error:

error: target not found: package-name

Solutions:

# Update package database
sudo pacman -Syu

# Search for package
pacman -Ss package-name

# Check if in AUR
yay -Ss package-name

Lock File Error

Error:

error: failed to lock database

Solution:

# Remove lock file (if pacman was interrupted)
sudo rm /var/lib/pacman/db.lck

# Verify no pacman process is running
ps aux | grep pacman

Signature Errors

Error:

error: package-name: signature from "..." is unknown trust

Solutions:

# Update keyring
sudo pacman-key --refresh-keys

# Initialize keyring (if needed)
sudo pacman-key --init
sudo pacman-key --populate archlinux

# Update archlinux-keyring
sudo pacman -Syu archlinux-keyring

Dependency Problems

Broken Dependencies

Check for broken dependencies:

# Check for broken packages
pacman -Qkk

# Check specific package
pacman -Qkk package-name

Fix broken dependencies:

# Reinstall package
sudo pacman -S package-name

# Reinstall all packages (extreme)
sudo pacman -S $(pacman -Qnq)

Orphaned Packages

Find orphaned packages:

# List orphaned packages
pacman -Qdt

# Remove orphaned packages
sudo pacman -Rns $(pacman -Qdtq)

What are orphaned packages?

  • Packages installed as dependencies
  • No longer needed by any package
  • Safe to remove

Package Conflicts

Conflicting Files

Error:

error: failed to prepare transaction (conflicting files)

Solutions:

# Check which package owns the file
pacman -Qo /path/to/conflicting/file

# Remove conflicting package
sudo pacman -R conflicting-package

# Force overwrite (use with caution)
sudo pacman -S --overwrite "*" package-name

Version Conflicts

Error:

error: failed to prepare transaction (conflicting dependencies)

Solutions:

# Check dependency tree
pacman -Qi package-name

# Update all packages
sudo pacman -Syu

# Remove conflicting package
sudo pacman -R conflicting-package

Performance Optimization

Parallel Downloads

Enable in pacman.conf:

[options]
ParallelDownloads = 5

Benefits:

  • Faster package installation
  • Downloads multiple packages simultaneously
  • Default in Pacman 7.1 (2025)

Package Cache

Manage cache:

# Check cache size
du -sh /var/cache/pacman/pkg

# Clean old packages
sudo pacman -Sc

# Clean all packages (frees space)
sudo pacman -Scc

Mirror Optimization

Use fastest mirrors:

# Install reflector
sudo pacman -S reflector

# Generate fast mirrors
sudo reflector --country "United States" --latest 10 --sort rate --save /etc/pacman.d/mirrorlist

Advanced Troubleshooting

Database Corruption

Check database:

# Check database integrity
sudo pacman-db-upgrade

# Rebuild database (if corrupted)
sudo pacman -Syu --overwrite "*"

Partial Upgrade Prevention

Never do partial upgrades:

# ❌ WRONG - Can break system
sudo pacman -Sy package-name

# ✅ CORRECT - Always use -Syu
sudo pacman -Syu package-name

Why?

  • Partial upgrades can cause dependency issues
  • System may become unstable
  • Always update database and packages together

Downgrade Package

Downgrade if needed:

# Install downgrade tool
sudo pacman -S downgrade

# Downgrade package
sudo downgrade package-name

Prevention & Best Practices

Regular Updates

Update schedule:

# Weekly updates (recommended)
sudo pacman -Syu

# Before major changes
# Always update first

Read Update Announcements

Check for breaking changes:

# Visit: https://archlinux.org/news/
# Read before updating
# Check for manual intervention needed

Backup Before Updates

Always backup:

# Backup important files
# Backup configuration
# Note current package versions

Use Official Repositories

Prefer official packages:

# Official repos are:
# - More reliable
# - Better maintained
# - Security updates
# - Use AUR only when needed

Review AUR Packages

Before installing from AUR:

# Check package page
# Read comments
# Review PKGBUILD
# Check last update date

Summary

This guide covered pacman tips, tricks, and troubleshooting techniques for Arch Linux.

Key Takeaways:

  • Always use -Syu for updates (never -Sy alone)
  • Check for orphaned packages regularly
  • Use parallel downloads for speed
  • Read update announcements
  • Backup before major updates

Next Steps


This guide is based on the ArchWiki. For the most up-to-date information, always refer to the official ArchWiki. Updated for Pacman 7.1 (2025).