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.Edit: formatting. I've over-done quotation marks to make it clear when precise wording matters.
Note: -S isn't "install," it's for syncing which does all manner of things including installs, but not removals (oddly enough). It's little things like this that bother me about pacman.
Working out the kinks was/is admittedly non-trivial. Read the directions. ;)
Edit: OK, 18 seconds. Still pretty good.
Just out of curiosity, what are Arch desktop users using for servers, where the rolling-release format isn't as acceptable?
pacman -Syu [pkgname] (I almost always use yu to ensure that things are always in sync)
pacman -Rsun pkgname
pacman -Qi pkgname
pacman -Sc (used every so often)
I would say those cover 99% of my interaction with pacman. I'm not sure of any other interfaces to use it so it would be interesting to know more about how you use pacman.
I'd add that I'd be careful about -n on -R (don't back up configuration files when removing a package); I'd let pacman back them, then catch them in my usual `sudo find /etc -name '.pac'`.
But seriously, alias commands you use, no need to remember the oddities.