pacman manages installed package records and configured Arch repositories.
The local database records installed versions, reasons, files, and ownership;
sync databases describe repository packages. Keep those views coherent by
refreshing and upgrading in one transaction.
Inspect the Local Database #
Use -Q for installed-package queries:
pacman -Qs '^bash$'
pacman -Qi bash
pacman -Ql bash
pacman -Qo /usr/bin/pacman
pacman -Qk-Ql lists files supplied by an installed package, -Qo finds the owner of
an existing path, and -Qk checks tracked files. pacman -F instead searches
the repository file database; populate it first with sudo pacman -Fy.
Package installation reasons affect orphan detection. Inspect or change one deliberately:
pacman -Qi package-name
sudo pacman -D --asexplicit package-name
sudo pacman -D --asdeps package-nameSynchronize and Upgrade Safely #
Search and inspect configured repositories with -Ss and -Si. A normal
system update is:
sudo pacman -Syu-y refreshes sync databases and -u upgrades the installed system against
that same repository state. Do not perform partial upgrades such as
pacman -Sy package-name: refreshed metadata can require dependencies newer
than the installed system. Read Arch news and resolve configuration-file
instructions before confirming a large transaction.
Install a repository package with sudo pacman -S package-name. Install a
locally built or cached archive with sudo pacman -U file.pkg.tar.zst; pacman
still resolves needed dependencies from configured repositories.
Remove Packages and Orphans Deliberately #
pacman -R package-name removes the target. -Rs also removes dependencies
made unneeded by that target; -Rns additionally removes retained backup
files. Review the proposed removal list before accepting it, because recursive
removal can remove dependency packages that another local workflow still
expects even when pacman’s dependency graph no longer requires them.
List potential orphans before removing them:
pacman -Qdt
pacman -QtdqOnly remove names after reviewing the list. An empty pacman -Qtdq result is
not an error to work around with an unguarded command substitution.
Preserve Recovery Options #
The default cache directory is /var/cache/pacman/pkg. Retain
recent versions; paccache from pacman-contrib can prune older entries while
keeping a selected count. A controlled downgrade uses a compatible cached
archive:
sudo pacman -U /var/cache/pacman/pkg/package-old.pkg.tar.zstDowngrading a library may require matching dependent packages. Inspect
dependency constraints and plan a coherent transaction rather than replacing
files under /usr, which bypasses pacman’s database, hooks, and ownership
model. For interrupted or damaged installations, consult /var/log/pacman.log,
reinstall affected packages with pacman, and restore files from a verified
backup where necessary.
Keep Signature Verification Enabled #
Repository and package signatures protect the supply chain. Fix expired,
missing, or revoked trust through archlinux-keyring, pacman-key, system
time, and documented mirror configuration; do not disable signature checks to
complete an update. Signature errors are evidence that must be understood
before packages are installed.
Comments
Read or comment on GitHub (sign-in required to comment)