Pacman is the package manager that defines the Arch Linux experience. Unlike APT or DNF, Pacman manages packages as compressed archives and operates on a single-operation philosophy — every action is clean, fast, and explicit. Once you understand its flag syntax and think in Pacman’s terms, managing a rolling-release system becomes second nature. This guide covers everything from daily commands to advanced strategies.
Understanding Pacman’s Flag Syntax
Pacman uses single uppercase letters as operation flags, combined with lowercase modifier flags. Once you see the pattern, it clicks:
| Operation | Flag | Meaning |
|---|---|---|
| Sync | -S |
Install, upgrade, or search packages from repositories |
| Remove | -R |
Remove installed packages |
| Query | -Q |
Query the local package database |
| Files | -F |
Query the file database |
| Database | -D |
Manipulate the package database directly |
| Upgrade | -U |
Install a local .pkg.tar.zst file |
Common modifier flags used alongside operations:
| Modifier | Meaning |
|---|---|
-y |
Refresh the package database (sync) |
-u |
Upgrade all out-of-date packages |
-s |
Search |
-i |
Show package info |
-l |
List files owned by a package |
-c |
Clean cache (1× = outdated, 2× = all) |
-n |
Also remove config files |
-d |
Skip dependency checks |
-q |
Quiet output |
1. Keeping the Package Database Up to Date
Before installing anything, sync your local package database with the remote repositories:
|
|
Note: Avoid installing a package immediately after
-Syalone. Partial upgrades on Arch can break your system because Arch is a rolling release — libraries and dependencies are always in sync when you do a full upgrade. Always do-Syutogether:
|
|
This refreshes the database and upgrades every out-of-date package in one shot. Running this regularly is the single most important habit on an Arch system.
2. Installing Packages
|
|
Examples:
|
|
Pacman will show a list of packages (including dependencies) and ask for confirmation before proceeding. Press Y or just Enter to continue.
Install a Specific Package Group
Arch organises related packages into groups. Install all packages in a group at once:
|
|
3. Removing Packages
|
|
The -Rns form is the cleanest uninstall — it leaves nothing behind. This is the recommended form when you are done with a package for good.
Tip:
-Rsis safe for everyday removals. The extra-nremoves config files from/etc— skip it if you plan to reinstall later and want to keep your settings.
Remove Multiple Packages
|
|
4. Upgrading the System
|
|
Use -Syyu after switching mirrors or if you suspect your local database is out of sync with the mirror.
Upgrade a Single Package
Pacman does not have a dedicated single-package upgrade flag — just install it again and it will upgrade:
|
|
Or upgrade only packages that are already installed (no new installs):
|
|
5. Searching for Packages
|
|
Example — searching for nginx:
|
|
Sample output:
extra/nginx 1.24.0-1
Lightweight HTTP server and IMAP/POP3 proxy server
extra/nginx-mainline 1.25.3-1
Lightweight HTTP server and IMAP/POP3 proxy server (mainline version)
6. Querying Package Information
Show Details About a Package (Remote)
|
|
Shows version, description, dependencies, conflicts, download size, installed size, and repository.
Show Details About an Installed Package
|
|
This reads from the local database — no network required.
List Files Installed by a Package
|
|
Find Which Package Owns a File
|
|
Output:
/usr/bin/curl is owned by curl 8.4.0-1
List All Installed Packages
|
|
List Only Explicitly Installed Packages
Packages you installed manually (not pulled in as a dependency):
|
|
List Only Dependency Packages
Packages installed only because something else required them:
|
|
7. Finding Orphaned Packages
Orphans are packages that were installed as dependencies but are no longer required by anything:
|
|
If the output is not empty, remove them:
|
|
Caution: Review the list before removing. On rare occasions, a package you use directly gets flagged as an orphan if it was installed as a dependency and then its parent was removed. Glance at the names before confirming.
8. Cleaning the Package Cache
Pacman caches every downloaded package in /var/cache/pacman/pkg/. On a rolling-release system this grows quickly.
|
|
Tip: Keep at least one or two old cached versions before running
-Scc. If an upgrade introduces a regression, a cached older package lets you downgrade without re-downloading.
Automatic Cache Management with paccache
paccache (from the pacman-contrib package) is smarter — it keeps the last N versions of each package:
|
|
Run paccache on a schedule with a systemd timer:
|
|
This runs paccache -r weekly automatically.
9. Downgrading a Package
Arch does not have a built-in downgrade command, but the package cache makes it straightforward:
|
|
After downgrading, prevent the package from being upgraded again until you are ready:
|
|
|
|
Remove it from IgnorePkg when you want to upgrade again.
10. Installing a Local Package File
If you have built a package from the AUR or downloaded a .pkg.tar.zst directly:
|
|
11. The AUR — Arch User Repository
The official repositories cover thousands of packages, but the AUR adds tens of thousands more — community-maintained build scripts (PKGBUILD files) for software not in the official repos.
Installing from the AUR Manually
|
|
makepkg -si builds the package and installs it (and its dependencies) in one step.
AUR Helpers
AUR helpers automate the manual process above. yay and paru are the most popular:
Installing yay:
|
|
Using yay (same syntax as Pacman plus AUR support):
|
|
Security note: AUR packages are community-maintained. Always read the
PKGBUILDbefore building — it is a shell script that runs with your user’s permissions. Trusted helpers likeyaywill show you the diff before building.
12. Checking for Package Issues
Verify Package Integrity
Check that all installed package files are present and unmodified:
|
|
A single k checks that files exist; double kk also validates file checksums (slower but thorough):
|
|
List Packages That Have No Files (Likely Broken)
|
|
Fix a Corrupted Database Lock
If Pacman crashes mid-operation, it may leave a lock file that prevents further use:
|
|
Only remove this file if you are certain no Pacman process is running.
pacman.conf — Key Configuration Options
The main Pacman configuration file is /etc/pacman.conf. A few settings worth knowing:
|
|
Enable colour and parallel downloads for a much more pleasant experience:
|
|
Uncomment or add Color and set ParallelDownloads = 5.
Quick Reference Cheat Sheet
| Task | Command |
|---|---|
| Update package database | sudo pacman -Sy |
| Full system upgrade | sudo pacman -Syu |
| Install a package | sudo pacman -S <pkg> |
| Install a package group | sudo pacman -S <group> |
| Remove a package | sudo pacman -R <pkg> |
| Remove + unused deps | sudo pacman -Rs <pkg> |
| Remove + deps + config | sudo pacman -Rns <pkg> |
| Search remote repos | pacman -Ss <keyword> |
| Search installed packages | pacman -Qs <keyword> |
| Show remote package info | pacman -Si <pkg> |
| Show installed package info | pacman -Qi <pkg> |
| List files from a package | pacman -Ql <pkg> |
| Find package owning a file | pacman -Qo /path/to/file |
| List all installed packages | pacman -Q |
| List explicitly installed | pacman -Qe |
| List orphaned packages | pacman -Qdt |
| Remove all orphans | sudo pacman -Rns $(pacman -Qdtq) |
| Clean old package cache | sudo pacman -Sc |
| Clean all package cache | sudo pacman -Scc |
Install local .pkg file |
sudo pacman -U /path/to/pkg.tar.zst |
| Downgrade from cache | sudo pacman -U /var/cache/pacman/pkg/<pkg>.tar.zst |
| Verify package files | sudo pacman -Qk |
| Remove database lock | sudo rm /var/lib/pacman/db.lck |
Rolling Release Habits Worth Building
Always run sudo pacman -Syu — never -Sy alone. Partial upgrades break Arch. If you refresh the database and install a single package without upgrading everything else, you may install a version that requires a newer library than what is on your system. Do the full upgrade every time.
Read the Arch Linux news before upgrading. The Arch Linux news page announces breaking changes and required manual interventions before they hit the mirrors. A five-second check before a major upgrade has saved many systems from a broken boot.
Keep your package cache before paccache -rk1. If an upgrade breaks something, having the previous version cached means a one-command rollback. Keep at least two versions unless disk space is genuinely critical.
Use pacman -Qdt regularly. Orphaned packages are not automatically harmful, but they accumulate over time. A monthly cleanup keeps your system lean and makes it easier to reason about what is installed and why.
Check IgnorePkg after resolving issues. When you add a package to IgnorePkg to hold it back, set a reminder to remove it later. Packages stuck on old versions get further and further behind and become harder to upgrade cleanly.
