pacman: The Arch Linux Package Manager

pacman is Arch Linux’s package manager. It is famously concise — most commands are one or two letters. After a week of using it, you’ll find apt and dnf verbose by comparison.

The flag mnemonics

pacman commands have a structure: -OPERATION SUBOPTIONS package. The operations:

  • -S = Sync (install / upgrade from repos)
  • -R = Remove
  • -Q = Query (about installed packages)
  • -U = Upgrade from local file
  • -F = File search

Suboptions modify behavior: y = refresh, u = upgrade, s = search, i = info.

Daily commands

# Refresh + upgrade everything (the daily command)
sudo pacman -Syu

# Install
sudo pacman -S nginx

# Install multiple
sudo pacman -S nginx git tmux htop

# Install without confirmation
sudo pacman -S --noconfirm nginx

# Remove (keeps config)
sudo pacman -R nginx

# Remove + dependencies it brought in
sudo pacman -Rs nginx

# Remove + config files
sudo pacman -Rn nginx

# Remove + deps + config files (the "really gone" combo)
sudo pacman -Rns nginx

Search and inspect

pacman -Ss nginx                # search remote repos
pacman -Si nginx                # info about a package in repo
pacman -Q                        # all installed packages
pacman -Qs nginx                # search installed packages
pacman -Qi nginx                # info about installed package
pacman -Ql nginx                # files installed by package
pacman -Qo /usr/bin/nginx       # which package owns this file?
pacman -Qdt                      # orphan packages (no longer needed)

Critical: never partial-update

Arch is a rolling release. Doing pacman -Sy foo (refresh metadata, install foo) without upgrading the whole system can leave foo expecting a newer libc than you have. Always use -Syu to upgrade EVERYTHING when you sync.

# GOOD
sudo pacman -Syu nginx

# BAD — partial upgrade, can break the system
sudo pacman -Sy nginx

Cleanup

# Remove orphans
sudo pacman -Rns $(pacman -Qdtq)

# Clear cache (keep last 3 versions)
sudo paccache -r

# Clear ALL cache
sudo pacman -Scc

The AUR (Arch User Repository)

The AUR is a community-maintained collection of build scripts (PKGBUILDs) for software not in official repos. Almost everything is in the AUR. But the AUR is user-submitted code that runs on YOUR machine — read PKGBUILDs before installing.

Use a helper like yay or paru:

# Install yay first (one time, manual)
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay && makepkg -si

# Then use yay like pacman, with AUR support
yay -S google-chrome           # install from AUR
yay -Syu                        # upgrade everything (repos + AUR)
yay -Ss spotify                 # search AUR + repos

List explicitly installed (vs auto-pulled)

pacman -Qet                     # explicitly installed and not required by anything
pacman -Qe                       # all explicitly installed
pacman -Qd                       # installed as dependencies

Useful when reinstalling: pacman -Qet > my-packages.txt on the old system, then pacman -S - < my-packages.txt on the new one.

Find what package provides a file

# For installed files
pacman -Qo /usr/bin/curl

# For files in any package (need pacman -Fy first to update file db)
sudo pacman -Fy
pacman -F bin/htop

Check for issues after upgrade

Read pacman’s output. It often warns about config file changes (.pacnew, .pacsave). Find them:

find /etc -name "*.pacnew" -o -name "*.pacsave"

Tools like pacdiff help you merge them.

Common mistakes

  • Partial upgrade with -Sy instead of -Syu.
  • Installing AUR packages without reading the PKGBUILD.
  • Ignoring .pacnew files — leaves you with old config and new package.
  • Running pacman -Rdd — removes without dep checking. Used incorrectly = broken system.

What to learn next

Now that package management is covered, the networking section is up. Reading IPs, opening ports, configuring SSH — the daily server admin work.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *