Pacman is the standard package manager for all Arch-based systems. While its usage is actually fairly simple, it may initially throw off users who are used to the APT or RPM family of packaging tools.
Unlike apt-get or yum, where you name a utility and tell it what to do (e.g. apt-get install [package] or yum search [package]), Pacman integrates the operation into its flags, as an uppercase letter, and options as lowercase letters. For example,
# pacman -Syu
specifies the operation given by “-S”, with the options given by “-yu”. While this may take a little getting used to, it also makes for a much easier-to-type command. In Debian, to find detailed handbrake information in the cache, I would type “apt-cache -pf search handbrake”. To do this with Pacman, I would simply type “pacman -Qi handbrake”.
With this in mind, let’s start looking at some common Pacman operations first. They’ll be explained more in depth later.
The standard syntax for Pacman is:
# pacman -OPERATION+options package
The most common things to do with Pacman seem to be installing packages, looking for packages, and upgrading everything.
To install a certain package, use:
# pacman -S [package]
where [package] is your target package. This is one of the simplest commands Pacman accepts. Note the crunch at the prompt: You’ll need root access to install software, for obvious reasons.
If you know your package is out there, but don’t know exactly what it’s called, you can use this following command to search for it:
# pacman -Ss [package]
This is like the install command, but the -s flag tells Pacman to search the remote repository instead.
If you want to upgrade everything on your system, you’ll need to tell Pacman to refresh your package lists and then upgrade everything out of date. To do this, issue
# pacman -Syu
This runs Pacman -S with the -y and -u flags. These options tell Pacman to upgrade everything that’s out of date on the system.
Now that you’re starting to get a grip on Pacman, let’s launch into the meatier stuff.
When syncing, Pacman will make your computer stuff look like the version on the server. This allows you to install packages, synchronize package lists, look up programs, and upgrade packages. You already learned how to install a basic package with the vanilla -S flag.
# pacman -S [package]
In the event that you already have certain files on the computer, Pacman will not blindly overwrite them, Use the -f flag on a sync forces Pacman to override the local files. This can be useful, for instance, if you accidentally installed a bad tarball and want to override the files. Use with caution, as you can easily break things.
# pacman -Sf [package]
The -c flag clears the cache of packages. Use it once to clear uninstalled packages from the cache, use it twice to flush everything into the bit bucket.
# pacman -Sc
You’ve probably seen enough syntax examples now to figure out the rest. We’ll save your eyes and give you only the good stuff from now on.
The -s flag will let you simply search for a package from the repositories. The -i flag will give you detailed information on it, the same information as -Qi (more on that below). Both are excellent tools for querying the repositories before you install, especially for Arch, which tends to have program-sparse repositories.
The -u flag upgrades ALL packages on your system. Use with caution, and don’t upgrade in the middle of an important project unless your distro is a stable release of Arch (yeah right). The -y flag refreshes the package list, and it should be used anytime you use the -u flag.
Excellent. Now you’ve installed your packages and done a full system upgrade, only to find that there’s a program that you didn’t mean to install. Whoops. If only there were some friendly option that would allow us to remove a package…
Fortunately, the -R option allows us to remove packages from the system. Unfortunately, the -R operation by itself will only remove the packages you specify. To remove unneeded dependencies, use the -s option. Repeating the flag (pacman -Rss) will remove explicitly installed dependencies as well. Note that Pacman will not remove anything that is still required by another program.
Finally, you can use the -c option (cascade) to remove all packages that depend on your target, and all packages that depend on those packages. Be cafeul when using this, as there is huge potential to break a lot of stuff.
Wait, didn’t we just cover an upgrade option with -Syu? Why would we need to have a second way to upgrade stuff?
The upgrade option for Pacman allows you to upgrade packages selectively, in case you just want VLC 2.0 without getting a new kernel as well. To upgrade a single package, use the -U flag by itself. Note that upgrading is a “remove-and-install” process.
This operation can also be used to downgrade a package, by finding the old package in /var/cache/pacman/ and using it as the target–pacman will uninstall the current package and “upgrade” it to the one you specify.
Just like when syncing, the -f option can be used when upgrading to force Pacman to overwrite existing files. Once again, this should be used with caution.
Query allows you to ask Pacman about the status of local packages, instead of remote ones. In a lot of ways, -Q is a lot like -S, except that you can’t install new packages with it. The basic command without extra options will look at package names.
To view the changelog of a package on your system, use the -c flag. NOTE that in spite of -Q and -S being relatively similar, the -c flag in Sync has a competely different function.
Just like in Sync, the -i and -s flags allow you to list detailed information on a package and search through its title and description, respectively. Note that the -s flag takes regular expressions, if you are familiar with those.
If you want to find all the out-of-date packages in the system, you can use the -u flag. Keep in mind that this is probably best done after you refresh your package lists, with -Sy.
Finally, the -d and -e flags allow you to search for packages that were only installed explicitly (-e), or only installed as dependencies (-d)
These options should be relatively simple to use. The -V flag will print out the version and then exit, while the -h option, when appended to any operation, will list out all other possible options.
In the event that you, for some reason, do not want to type out short options, Pacman supports long options for everything. For example, instead of
# pacman -Syyuf
you are free to type out
# pacman --sync --force --sysupgrade --refresh --refresh
While this usage of Pacman isn’t particularly svelte, if you feel like long options are easier to remember, by all means, use them. The long versions of flags can be found in the Pacman manpage.
While pkgfile isn’t strictly part of Pacman, it’s useful enough to warrant a mention here. pkgfile looks through your package cache and can identify which package a particular program/command is a part of. You can then plug that package into Pacman -S and have yourself a nice little program! This way, you can avoid trying to figure out which package a particular progam is a part of. For example, asking pkgfile to look for “sensors-detect” yields “extra/lm_sensors” on an Arch configuration.
We’d recommend updating your package lists before using this tool to make sure you get the most accurate information possible
# pacman -Sy # pkgfile [program name]
While the Arch repositories support many packages, they often don’t support more niche projects or anything that they feel does not fit well with the spirit of Arch.
Fortunately, there are several tools that can help you access the AUR directly from Pacman. Unfortunately, since none of them are officially supported, you’ll have to either compile them from source or use wget to pull the package off of the AUR and compile it.
The most popular AUR helper seems to be yaourt, with Packer offering yaourt-like support without quite as much bloat. The syntax for yaourt and packer is identical to that of Pacman. They will search the AUR in addition to any repositories you specify for Pacman.
Remember that packages in the Arch User Repositories is not scanned or officially supported. Make sure you know what you’re downloading.
What if you like graphical user frontends? Unfortunately, Arch does not come with a graphical user interface by default, nor does the Arch project officially support one. However, there are several GUIs for download from the Arch User Repository (more on this below). There is one manager that is not specifically designed for any particular DE, pacmanxg, and it can be installed by using your favorite AUR helper or manually pointing with wget.
# packer -S pacmanxg4-bin
Once installed, packmanxg has very much the feel of Synaptic or another simple package manager. It is certainly not a full-blown software center as is found in Ubuntu or Linux Mint. In fact, the only reason I can see to use the GUI is for package browsing. For installing packages with known names, the command-line Pacman is probably both faster and easier. How’s that for the Arch Linux philosophy?