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 -Syuis 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
pacmanis half the journey to using the AUR safely with helpers likeyay.
pacmanis 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:
| Flag | Meaning |
|---|---|
-R | Remove the package; config files stay. |
-Rs | Also remove packages that depend on it. |
-Rn | Also 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 -Syalone). 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 -Syuas 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.
yayis convenient but not a security review. - Running
pacman -Rand wondering where the config went.-Rkeeps config files; if you want them gone, use-Rns. - Confusing
pacman -Swithapt install.pacman -Sinstalls and upgrades; there is no separate “install” command. - Forgetting to clean the cache. On a rolling release the cache grows fast;
-Scoccasionally keeps it reasonable.
Related Pages
| Page | Why it is here |
|---|---|
| Package Management | The concept section — packages, repos, and why managers exist. |
| apt | The same job on Debian and Ubuntu. |
| dnf | The same job on Fedora and RHEL systems. |
| snap | Cross-distro packages that can coexist with pacman. |
| flatpak | Desktop apps delivered independently of the system repos. |
| sudo | Why most of these commands need it. |
pacman Cheatsheet
| Command | What it does |
|---|---|
sudo pacman -Syu | Refresh databases and upgrade every package. |
sudo pacman -S firefox | Install (or upgrade) a package. |
sudo pacman -S base-devel | Install a package group. |
sudo pacman -U ./file.pkg.tar.zst | Install or upgrade from a local file. |
sudo pacman -R htop | Remove a package, keep its config. |
sudo pacman -Rns htop | Remove a package, its config, and orphans. |
pacman -Qdt | List orphaned packages. |
pacman -Ss editor | Search repository packages. |
pacman -Si firefox | Show repository package details. |
pacman -Qs editor | Search installed packages. |
pacman -Q | List every installed package. |
pacman -Qi firefox | Show installed package details. |
pacman -Ql firefox | List files owned by an installed package. |
pacman -Qo /usr/bin/firefox | Find which package owns a file. |
pacman -Sy | Refresh databases only (partial upgrade trap). |
pacman -Sc | Clean the package cache, keep current versions. |
pacman -Scc | Clean the entire package cache. |