pacman, the Arch Linux package manager
pacman is the program Arch Linux uses to install, upgrade, remove and query software packages, and it is driven by a single capital operation letter: -S to synchronise, -R to remove, -Q to query, -U to install a local package file.
sudo pacman -Syu
-S- --sync — install packages from the repositories and upgrade the system
-y- --refresh — refresh the package databases from the mirrors
-u- --sysupgrade — upgrade every installed package that is out of date
Needs root.
What it does. Refresh the package databases from the mirrors, then upgrade every installed package.
Watch out. Refreshing without upgrading — a bare -Sy — is the one mistake worth memorising.
This site documents pacman, the package manager of Arch Linux and the distributions built on it. It is not about the similarly spelled arcade video game.
How a pacman command is shaped
A pacman command has three parts, and reading them in order is enough to understand one you are handed:
pacman -<operation><modifiers> <targets>The shape of a command, not a command: the angle brackets are where your own letters and names go.
The operation is one capital letter and there is exactly one of them. The
modifiers are lowercase letters that attach to it, so -Syu is the operation -S with
the modifiers y and u. The targets are the package names, file paths or search
patterns the operation works on.
The same lowercase letter means different things under different operations,
which is the part that makes pacman look cryptic. s under -R means
recursive; the same s under -S means search. That is not an
inconsistency to memorise one command at a time — it is why this site has
a command explainer that reads the letters for you.
The operations
Six operations cover the commands most people ever type. Start from what you want to do and the letter follows from it:
| Letter | Long form | What it does | Root? | Can destroy? |
|---|---|---|---|---|
-S | --sync | Install packages from the repositories and upgrade the system | yes | yes, with -Sc or -Sy used alone |
-R | --remove | Remove installed packages | yes | yes, that is its job |
-Q | --query | Ask the local database what is installed | no | no |
-U | --upgrade | Install a package from a local package file | yes | yes |
-D | --database | Change how a package is recorded in the database | yes | no files change, but later removals do |
-F | --files | Find which repository package owns a file | no, except -Fy | no |
-F is the one row where the answer has an
exception in it. Asking which package owns a file only reads, but
-Fy downloads the file databases into /var/lib/pacman
first, and writing there needs root.
Three more exist and are rarely typed by hand: -T reports which of the given
dependencies are unsatisfied, -V prints the version, and -h prints the help for
whichever operation you pair it with.
Start from the task, not the letter
If you know what you want to do, go straight to the page for it.
| I want to… | Command | Page |
|---|---|---|
| Update everything | sudo pacman -Syu | Updating Arch |
| Install a package | sudo pacman -S <package> | Installing |
| Remove a package | sudo pacman -Rns <package> | Removing |
| See what is installed | pacman -Q | Listing installed packages |
| Find a package | pacman -Ss <pattern> | Searching |
| Free disk space | sudo pacman -Sc | Cleaning the cache |
| Change or fix mirrors | /etc/pacman.d/mirrorlist | The mirrorlist |
| Understand yay | yay -S <package> | yay vs pacman |
| Build from the AUR | makepkg -si | AUR helpers and makepkg |
| Fix a lock error | /var/lib/pacman/db.lck | The database lock |
| Look a command up | pacman -Qdt | The cheat sheet |
Read a command before you run it
Paste a pacman command into the command explainer: it names the letters it recognises, says whether the command needs root, and puts it at one of three levels — routine, caution or risky. It goes the other way round too: pick an operation and some modifiers, and it writes the command.
sudo pacman -Rdd glibcdd removes the package without checking dependencies, which is what makes this line worse than the removal it looks like.
The words that keep coming up
pacman is the package manager of Arch Linux: the program that installs, upgrades, removes and queries packages, and that keeps the local database describing which files belong to which package.
A repository is a collection of built, signed packages that pacman can install from. The ones configured by default in Arch are called the official repositories.
A partial upgrade is a system where some packages come from a newly refreshed database and the rest are still at older versions, which happens when the databases are refreshed without also upgrading.
An orphan is a package that was installed as a dependency of something else and that nothing installed requires any more.
Common questions
What is pacman on Arch?
pacman is the package manager of Arch Linux. It installs and upgrades packages from the configured repositories, removes them, and answers questions about what is installed on the machine and which package a file belongs to.
Does Arch use pacman instead of APT?
Yes. APT belongs to Debian and the distributions derived from it. Arch Linux uses pacman, with its own command syntax: one capital operation letter followed by lowercase modifiers, rather than a subcommand word.
Do I need sudo for every pacman command?
No. Commands that only read need no root: the -Q queries, -Ss searching the repositories, -Si, and asking -F which package owns a file. Root is needed when pacman writes, and that includes -Fy: installing, removing, refreshing either set of databases and cleaning the cache.