A quick overview of usage of the Pacman package manager
This was originally published on Hacker News on 2013-01-23.
Note: I've over-done quotation marks to make it clear when precise wording matters.
pacman
is a little awkward, but I prefer it to apt/dpkg, which have sub-commands, each with their own flags, some of which are undocumented. pacman, on the other hand, has ALL options documented in one fairly short man page.
The trick to understanding pacman is to understand how it maintains databases of packages, and what it means to "sync".
There are several "databases" that pacman deals with:
- "the database", (
/var/lib/pacman/local/
)
The database of currently installed packages - "package databases", (
/var/lib/pacman/sync/${repo}.db
)
There is one of these for each repository. It is a file that is fetched over plain http(s) from the server; it is not modified locally, only updated.
The "operation" of pacman is set with a capital flag, one of "DQRSTU" (plus -V
and -h
for version and help). Of these, "DTU" are "low-level" (analogous to dpkg) and "QRS" are "high-level" (analogous to apt).
To give a brief explanation of cover the "high-level" operations, and which databases they deal with:
- "Q" Queries "the database" of locally installed packages.
- "S" deals with "package databases", and Syncing "the database" with them; meaning it installs/updates packages that are in package databases, but not installed on the local system.
- "R" Removes packages "the database"; removing them from the local system.
The biggest "gotcha" is that "S" deals with all operations with "package databases", not just syncing "the database" with them.