Sat Apr 28 2018
All about Pacman in Arch
Pacman stands for Package Manager, and you might know that the Pacman is the default CLI package manager for Arch Linux and its derivatives. It is a utility which manages software packages in Linux. It uses simple compressed files as a package format and maintains a text-based package database. It never tries to do everything. It will simply add, remove and upgrade packages in the system, and will allow you to query the package database for installed packages and files. It also attempts to handle dependencies automatically and can download packages from a remote server.
Development
Development of Pacman is currently done in Git. The central repository is hosted by Arch Linux, although some of the developers have their own trees. The current development tree can be fetched with the following command: (git clone git://projects.archlinux.org/pacman.git Pacman), which will fetch the full development history into a directory named Pacman.
Utilities
Although the package manager itself is quite simple, many scripts have been developed that help automate building and installing packages, there are several utilities available -
abs - ABS (Arch Build System), scripts to download & use the Arch Linux PKGBUILD tree
dbscripts - scripts used by Arch Linux to manage the main package repositories
devtools - tools to assist in packaging and dependency checking
namcap - a package analysis utility written in python
srcpac - a bash build-from-source Pacman wrapper
Package installation
-
To install a single package or list of packages, issue the following command:
> sudo pacman -S package_name1 package_name2
-
To install a list of packages with regex:
> sudo pacman -S $(pacman -Ssq package_regex)
-
Sometimes there are multiple versions of a package in different repositories. To install the former version, the repository needs to be defined in front:
> sudo pacman -S extra/package_name
-
To install a number of packages sharing similar patterns in their names - but not the entire group nor all matching packages; eg. plasma:
> sudo pacman -S plasma-{desktop,mediacenter,nm}
-
And that is not limited, can be expanded to however many levels needed:
> sudo pacman -S plasma-{workspace{,-wallpapers},pa}
Package groups installation
-
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
> sudo pacman -S gnome
-
Sometimes a package group will contain a large number of packages, and you do or do not want to install every of them. So, it is sometimes more convenient to select or exclude packages or ranges of packages with the syntax like - Enter a selection (default=all): 1-10 15. It will select packages 1 through 10 and 15 for installation, or Enter a selection (default=all): ^5-8 ^2 which will select all packages except 5 through 8 and 2 for installation.
-
To see what packages belong to the gnome group, run:
> sudo pacman -Sg gnome
Removing packages
-
To remove a single package, leaving all of its dependencies installed:
> sudo pacman -R package_name
-
To remove a package and its dependencies which are not required by any other installed package:
> sudo pacman -Rs package_name
-
To remove a package, its dependencies and all the packages that depend on the target package:
>sudo pacman -Rsc package_name
-
But remember, this operation is recursive and must be used with care since it can remove many potentially needed packages.
-
To remove a package, which is required by another package, without removing the dependent package:
> sudo pacman -Rdd package_name
-
Pacman saves important configuration files when removing certain applications and names them with the extension:
> .pacsave. -
To prevent the creation of these backup files use the -n option:
> sudo pacman -Rn package_name
Packages upgradation
-
Pacman can update all packages on the system with only using one command. This dependence on while and how the system is up-to-date. The following command synchronizes the repository databases and updates the system's packages, excluding "local" packages that are not in the configured repositories:
> sudo pacman -Syu
Hope this article will help you to learn more about Pacman and commands will help you to use it in your system. Thank you!