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:

1
sudo pacman -Sy

Note: Avoid installing a package immediately after -Sy alone. 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 -Syu together:

1
sudo pacman -Syu

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

1
sudo pacman -S <package-name>

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Install a single package
sudo pacman -S curl

# Install multiple packages at once
sudo pacman -S git vim htop

# Install without a confirmation prompt
sudo pacman -S --noconfirm curl

# Reinstall a package (useful if files are corrupted)
sudo pacman -S <package-name>

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:

1
2
3
4
5
# Install the entire base-devel group (needed for AUR builds)
sudo pacman -S base-devel

# See what is in a group before installing
pacman -Sg base-devel

3. Removing Packages

1
2
3
4
5
6
7
8
# Remove the package only
sudo pacman -R <package-name>

# Remove the package and its unused dependencies
sudo pacman -Rs <package-name>

# Remove the package, its unused dependencies, AND config files
sudo pacman -Rns <package-name>

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: -Rs is safe for everyday removals. The extra -n removes config files from /etc — skip it if you plan to reinstall later and want to keep your settings.

Remove Multiple Packages

1
sudo pacman -Rns firefox thunderbird vlc

4. Upgrading the System

1
2
3
4
5
# Full system upgrade (most common command you will run)
sudo pacman -Syu

# Force-refresh databases even if Pacman thinks they are current
sudo pacman -Syyu

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:

1
sudo pacman -S <package-name>

Or upgrade only packages that are already installed (no new installs):

1
sudo pacman -Su

5. Searching for Packages

1
2
3
4
5
6
7
8
# Search the sync database (remote repositories) by name or description
pacman -Ss <keyword>

# Search only package names (faster, less noise)
pacman -Ss '^nginx$'

# Search your locally installed packages
pacman -Qs <keyword>

Example — searching for nginx:

1
pacman -Ss 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)

1
pacman -Si <package-name>

Shows version, description, dependencies, conflicts, download size, installed size, and repository.

Show Details About an Installed Package

1
pacman -Qi <package-name>

This reads from the local database — no network required.

List Files Installed by a Package

1
pacman -Ql <package-name>

Find Which Package Owns a File

1
pacman -Qo /usr/bin/curl

Output:

/usr/bin/curl is owned by curl 8.4.0-1

List All Installed Packages

1
2
3
4
5
6
7
pacman -Q

# With version numbers
pacman -Q | less

# Count total installed packages
pacman -Q | wc -l

List Only Explicitly Installed Packages

Packages you installed manually (not pulled in as a dependency):

1
pacman -Qe

List Only Dependency Packages

Packages installed only because something else required them:

1
pacman -Qd

7. Finding Orphaned Packages

Orphans are packages that were installed as dependencies but are no longer required by anything:

1
pacman -Qdt

If the output is not empty, remove them:

1
sudo pacman -Rns $(pacman -Qdtq)

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.

1
2
3
4
5
# Remove cached packages that are no longer installed (keep current versions)
sudo pacman -Sc

# Remove ALL cached packages (maximum space reclaim — no going back)
sudo pacman -Scc

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sudo pacman -S pacman-contrib

# Keep the 3 most recent versions of each package (default)
sudo paccache -r

# Keep only the 1 most recent version
sudo paccache -rk1

# Remove all cached versions of uninstalled packages
sudo paccache -ruk0

Run paccache on a schedule with a systemd timer:

1
2
sudo systemctl enable paccache.timer
sudo systemctl start paccache.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:

1
2
3
4
5
# List cached versions of a package
ls /var/cache/pacman/pkg/ | grep nginx

# Install a specific cached version
sudo pacman -U /var/cache/pacman/pkg/nginx-1.24.0-1-x86_64.pkg.tar.zst

After downgrading, prevent the package from being upgraded again until you are ready:

1
2
# In /etc/pacman.conf, add the package to IgnorePkg:
sudo nano /etc/pacman.conf
1
IgnorePkg = nginx

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:

1
2
3
4
sudo pacman -U /path/to/package.pkg.tar.zst

# Install from a URL
sudo pacman -U https://example.com/package.pkg.tar.zst

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

1
2
3
4
5
6
7
8
9
# Install the git and base-devel group first
sudo pacman -S git base-devel

# Clone the AUR package repository
git clone https://aur.archlinux.org/package-name.git

# Enter the directory and build
cd package-name
makepkg -si

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:

1
2
3
4
sudo pacman -S git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Using yay (same syntax as Pacman plus AUR support):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# System upgrade including AUR packages
yay -Syu

# Search AUR + official repos
yay -Ss <keyword>

# Install an AUR package
yay -S <aur-package-name>

# Remove an AUR package
yay -Rns <package-name>

Security note: AUR packages are community-maintained. Always read the PKGBUILD before building — it is a shell script that runs with your user’s permissions. Trusted helpers like yay will show you the diff before building.


12. Checking for Package Issues

Verify Package Integrity

Check that all installed package files are present and unmodified:

1
sudo pacman -Qk

A single k checks that files exist; double kk also validates file checksums (slower but thorough):

1
sudo pacman -Qkk 2>&1 | grep -v ': 0 missing'

List Packages That Have No Files (Likely Broken)

1
pacman -Qkq 2>&1 | grep -v 'warning:'

Fix a Corrupted Database Lock

If Pacman crashes mid-operation, it may leave a lock file that prevents further use:

1
sudo rm /var/lib/pacman/db.lck

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Ignore a package during upgrades
IgnorePkg = linux linux-headers

# Ignore an entire group
IgnoreGroup = plasma

# Enable colour output
Color

# Show download progress bars
VerbosePkgLists

# Parallel downloads (default: 1, increase for faster downloads)
ParallelDownloads = 5

Enable colour and parallel downloads for a much more pleasant experience:

1
sudo nano /etc/pacman.conf

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.