Home » Categories » Linux Cloud Server » ArchLinux |
How To Use Arch Linux Package Management |
Article Number: 170 | Rating: Unrated | Last Updated: Sun, Jan 5, 2014 at 8:06 PM
|
Arch Linux provides package management facilities similar to those found in other modern Linux distributions. This is a guide to common package management operations. Before proceeding further, make sure your package databases are up to date with:
SearchingFavoring brevity over intuitiveness, most package management operations in Arch Linux appear in the format:
For example, the normal command for searching pacman repositories is
Like most pacman commands, it is not particularly obvious. pacman also ships with a pacsearch utility. It works similarly, but it has some enhancements over pacman -Ss:
Here is how you would list all standard packages with the keyword 'linux.'
Sometimes there will be a lot of packages matching your search criteria. This is especially true when using an AUR helper like yaourt. Regular expressions can help narrow down the list. For example, let's say you are trying to find anything related to the "ack" tool. A regular search for ack will inevitably return a lot of results to sift through, due to words like "package," "hack," or "playback."
However, not many words begin with ack. Adding a ^ to the search word will only include results that start with those letters. This works with at least pacsearch, pacman, and yaourt.
To guarantee a regular expression works as intended, surround it with quotes.
If you want to get a list of installed packages matching a search, pipe the results to "grep local." The "-A 1" option tells grep to include one line after each match (the package description, in this case).
Alternatively, you can use pacman -Qs with the downside of no color highlighting.
If you want color highlighting with pacman -Ss, you can uncomment Color from /etc/pacman.conf. It highlights different things than pacsearch, though, so you might want to try both and see which one you like better.
Getting Informationpacman -Qi
If pacman -Qi is passed no arguments, it returns all packages in the system. You can search this output to get specialized information about installed packages. For example, if you wanted to get each package and its size:
While pacman -Qi provides information about installed packages, pacman -Si queries the database for the most recently retrieved information about a package.
pacman -Ql
The package name on each line can make the output more difficult to use in a script. pacman -Qlq (i.e. "pacman query list, quiet") will not print the package name.
You can use pacman -Qlq
Storage ConsumptionThe simplest way to see which packages are taking up the most space on your system is pacsysclean which ships with pacman.
If you want something a little more complicated, the pacgraph utility can produce a dependency word cloud of the largest packages in SVG and PNG format. pacgraph is found in the community repository.
pacgraph -c will output to the console like pacsysclean. If there are a lot of packages, pacgraph's output can get unwieldy since it is sorted from largest to smallest, unlike pacsysclean. You can pipe it to head to just see biggest packages.
In the Arch Linux server instance I tested, some errors were produced before this output. To remove the errors, you will need to correct the locale settings from the default "C".
Run without any arguments, pacgraph produces an SVG and, if possible, a PNG file. If you don't have a file sharing system set up with your virtual server, the simplest way to access the images generated by pacgraph is to use Secure Copy.
Note: Although pacgraph will claim to render a PNG file after imagemagick and libpng are installed, at the time of this writing it will not actually generate a PNG without inkscape, which has quite a few dependencies. Downloads / InstallationThe typical way to install or upgrade a standard package is pacman -S.
Packages often have a similar pattern in their names. Brackets can be used as a shortcut.
Sometimes you might want to just download a package for archival purposes without installing it. pacman -Sw will download a package to the cache folder.
If a package has been downloaded, or if you know the url, you can install it directly.
UpgradesSince pacman revolves around the idea of "syncing" a package with the remote repository, pacman -S will upgrade a package if it is already installed. Pacman can list packages that are out of date.
Unfortunately, it doesn't display the version of the package in the repository, so you won't be able to tell how out of date each package is. If this is important to you, you might want to look into 3rd party package managers or write a script that ties together the package version obtained from pacman -Qi and pacman -Si. You can get the version from pacman -Qi or pacman -Si using a regular expression.
And then write a script that shows the versions side by side.
Pacman provides a way to upgrade all of your packages at once, but it is not recommended because Arch is a rolling release distribution. If problems arise, it can take time to determine what the causes are.
DowngradesArch Linux does not officially maintain deprecated packages. Instead, you will need to rely on your package cache and places like the Arch Rollback Machine. CacheEvery package downloaded with pacman is stored in /var/cache/pacman/pkg.
If you would like to revert to a package in your cache, just install it directly.
Arch Rollback MachineThe Arch Rollback Machine is a collection of snapshots of the official Arch Linux mirror. As of this writing, it goes back four months. The ARM is currently hosted at http://seblu.net/a/arm, though this could change in the future. ARM packages can be installed remotely using pacman -U
It isn't exactly convenient to browse the ARM for older packages. Fortunately, there are tools that make this easier: They search for older versions in the cache and the ARM. Their usage is what you would expect.
Both tools are in the AUR, so the easiest way to install them will be with a helper like yaourt. Note: The ARM is an unofficial project and has been closed in the past, so it might be a good idea to avoid clearing your cache in case the ARM goes down or changes locations again. If you would like to roll your own ARM, there appears to be a NodeJS project on github. RemovalRemove a package, provided nothing is depending on it. Leave its dependencies installed.
Remove a package, provided nothing is depending on it. Remove its dependencies that aren't required by anything else.
Force removal of a package. This is the command you will reach for to just wipe the package from your system and reinstall when reinstalling alone isn't enough.
Unofficial PackagesThe vast majority of Arch Linux packages are located in the Arch User Repository. The best way to search for and download packages from the AUR is to use a helper tool. |
Attachments
There are no attachments for this article.
|
How To Deploy Node.js Applications Using Systemd and Nginx
Viewed 9569 times since Sat, Jan 4, 2014
How To Create a SSL Certificate on Apache on Arch Linux
Viewed 3344 times since Sun, Dec 29, 2013
How To Install Ruby on Rails on Arch Linux with RVM
Viewed 13838 times since Sun, Dec 29, 2013
Initial Server Setup with Arch Linux
Viewed 3490 times since Fri, Dec 27, 2013
Installing and Using the Vim Text Editor on a Cloud Server
Viewed 2521 times since Fri, Dec 27, 2013
How To Use Yaourt to Easily Download Arch Linux Community Packages
Viewed 4115 times since Fri, Dec 27, 2013
How To Install Wordpress on Arch Linux
Viewed 2572 times since Sun, Dec 29, 2013
How to Add a Swap File on an Arch Linux Cloud Server
Viewed 2632 times since Fri, Dec 27, 2013
How To Install (LEMP) nginx, MySQL, PHP stack on Arch Linux
Viewed 13593 times since Sun, Dec 29, 2013
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Arch Linux
Viewed 4504 times since Fri, Dec 27, 2013
|