Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

pacman Command Guide for Installing Software on Arch Linux

pacman is Arch Linux’s package manager — simple, fast, and explicit: it manages packages, syncs with repositories, and keeps the system clean.


What is pacman, and Why Use It?

pacman is the package manager for Arch Linux and its derivatives (Manjaro, EndeavourOS, SteamOS). It installs packages from official repositories and the AUR (Arch User Repository), resolves dependencies, and keeps the package database in sync with the disk. pacman is deliberately minimal and explicit — it gives you exactly what you ask for and warns loudly when something unusual is about to happen.

Why Learn pacman?

  • It is the front door to Arch — every piece of software on an Arch system, from the kernel to your web browser, arrives through pacman.
  • Rolling-release simplicity — pacman -Syu is the entire system-update ritual; there is no “upgrade path” to negotiate.
  • It teaches the package model clearly — the commands are the smallest set that covers sync, install, remove, query, and file ownership.
  • AUR awareness — understanding pacman is half the journey to using the AUR safely with helpers like yay.

pacman is the quiet workhorse of Arch: five subcommands, one database, and a philosophy that says the system should do exactly what you said — and warn you when it cannot.


1. The Full System Update

Arch is a rolling release: there are no “versions” to upgrade between. Updating means one command:

sudo pacman -Syu

-Syu syncs the package databases (-y), then upgrades (-u) every installed package (-S). This is the entire update ritual — run it regularly, because partial upgrades (some packages new, some old) can break the system.

To update a single package:

sudo pacman -S htop        # install or upgrade one package

-S means “sync”: if the package is not installed, it installs it; if it is, it upgrades it. Install and upgrade are one operation.


2. Installing Packages

sudo pacman -S firefox        # install firefox
sudo pacman -S base-devel     # install a group (development tools)

pacman resolves dependencies automatically. For packages that are not in the official repos, use an AUR helper (like yay) — but see the pitfalls below.

To install a local package file (rarely needed on Arch):

sudo pacman -U ./some-package.pkg.tar.zst

-U upgrades or installs a package from a local file, resolving dependencies from the repos first.


3. Removing Packages

sudo pacman -R htop           # remove htop (keeps its config files)
sudo pacman -Rns htop         # remove htop AND its config AND orphaned dependencies

The three flags are the important part:

FlagMeaning
-RRemove the package; config files stay.
-RsAlso remove packages that depend on it.
-RnAlso remove its config files.

-Rns is the thorough removal; -R is the conservative one. pacman warns before removing anything that other packages might need.

To remove orphaned dependencies (packages installed as deps that nothing needs anymore):

sudo pacman -Qdt              # list orphaned packages
sudo pacman -Rns $(pacman -Qdtq)   # remove them

4. Searching and Inspecting

pacman -Ss editor             # search repo names and descriptions
pacman -Si firefox            # info about a repo package
pacman -Qs editor             # search only installed packages
pacman -Q                     # list every installed package
pacman -Qi firefox            # info about an installed package
pacman -Ql firefox            # list files owned by an installed package
pacman -Qo /usr/bin/firefox   # which package owns this file?

The two-letter mnemonics: S = sync (repositories), Q = query (installed). s = search, i = info, l = list files, o = own file.


5. Repository and Database Management

pacman -Sy                    # refresh package databases only
sudo pacman -Scc              # clean the package cache
pacman -Sc                    # clean cache, keep current versions

-Sy alone (without -u) is the partial upgrade trap: updating databases without upgrading packages can break the system on a rolling release. Always pair -y with -u (-Syu) unless you have a specific reason.

The package cache lives in /var/cache/pacman/pkg/; -Sc removes old versions, -Scc removes everything.


The AUR in One Paragraph

The AUR (Arch User Repository) is a community-maintained collection of build recipes (PKGBUILD files) for software not in the official repos. pacman itself does not install from the AUR — you use a helper like yay or paru:

yay -S google-chrome          # build and install from the AUR

Helpers handle the download, build, and install; the result is registered in pacman’s database like any other package. The AUR is a power-user feature: read the PKGBUILD before running it, and prefer official repo packages when they exist.


Common Pitfalls

  • Partial upgrades (pacman -Sy alone). On a rolling release, syncing databases without upgrading packages can leave the system in a state where new packages expect a newer core library than you have. Always -Syu.
  • Using pacman -Syu as root without checking news. Arch occasionally posts critical manual-intervention notices on its front page; read them before big updates.
  • Trusting the AUR blindly. AUR packages are community-built; always read the PKGBUILD and comments before installing. yay is convenient but not a security review.
  • Running pacman -R and wondering where the config went. -R keeps config files; if you want them gone, use -Rns.
  • Confusing pacman -S with apt install. pacman -S installs and upgrades; there is no separate “install” command.
  • Forgetting to clean the cache. On a rolling release the cache grows fast; -Sc occasionally keeps it reasonable.

PageWhy it is here
Package ManagementThe concept section — packages, repos, and why managers exist.
aptThe same job on Debian and Ubuntu.
dnfThe same job on Fedora and RHEL systems.
snapCross-distro packages that can coexist with pacman.
flatpakDesktop apps delivered independently of the system repos.
sudoWhy most of these commands need it.

pacman Cheatsheet

CommandWhat it does
sudo pacman -SyuRefresh databases and upgrade every package.
sudo pacman -S firefoxInstall (or upgrade) a package.
sudo pacman -S base-develInstall a package group.
sudo pacman -U ./file.pkg.tar.zstInstall or upgrade from a local file.
sudo pacman -R htopRemove a package, keep its config.
sudo pacman -Rns htopRemove a package, its config, and orphans.
pacman -QdtList orphaned packages.
pacman -Ss editorSearch repository packages.
pacman -Si firefoxShow repository package details.
pacman -Qs editorSearch installed packages.
pacman -QList every installed package.
pacman -Qi firefoxShow installed package details.
pacman -Ql firefoxList files owned by an installed package.
pacman -Qo /usr/bin/firefoxFind which package owns a file.
pacman -SyRefresh databases only (partial upgrade trap).
pacman -ScClean the package cache, keep current versions.
pacman -SccClean the entire package cache.