Installing specific packages
# pacman -S package_name1 package_name2 …
To install a list of packages with regex
# pacman -S $(pacman -Ssq package_regex)
To install the version from the extra repository
# pacman -S extra/package_name
To install a number of packages sharing similar patterns in their names one can use curly brace expansion. For example:
# pacman -S plasma-{desktop,mediacenter,nm}
This can be expanded to however many levels needed:
# pacman -S plasma-{workspace{,-wallpapers},pa}
Installing package groups
# pacman -S gnome
To see what packages belong to the gnome group
# pacman -Sg gnome
Removing packages
To remove a single package
# pacman -R package_name
To remove a package and its dependencies which are not required by any other installed package
# pacman -Rs package_name
To remove a package, its dependencies and all the packages that depend on the target package (This operation is recursive, and must be used with care since it can remove many potentially needed packages.)
# pacman -Rsc package_name
To remove a package, which is required by another package, without removing the dependent package (The following operation can break a system and should be avoided.)
# 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
# pacman -Rn package_name
Upgrading packages
Pacman can update all packages on the system with just one command. This could take quite a while depending on how up-to-date the system is. The following command synchronizes the repository databases and updates the system’s packages, excluding “local” packages that are not in the configured repositories:
# pacman -Syu
Querying package databases
Pacman queries the local package database with the -Q flag, the sync database with the -S flag and the files database with the -F flag.
$ pacman -Ss string1 string2 …
To search for already installed packages:
$ pacman -Qs string1 string2 …
To search for package file names in remote packages:
$ pacman -Fs string1 string2 …
To display extensive information about a given package:
$ pacman -Si package_name
For locally installed packages:
$ pacman -Qi package_name
Passing two -i flags will also display the list of backup files and their modification states:
$ pacman -Qii package_name
To retrieve a list of the files installed by a package:
$ pacman -Ql package_name
To retrieve a list of the files installed by a remote package:
$ pacman -Fl package_name
To verify the presence of the files installed by a package:
$ pacman -Qk package_name
Passing the k flag twice will perform a more thorough check.
To query the database to know which package a file in the file system belongs to:
$ pacman -Qo /path/to/file_name
To query the database to know which remote package a file belongs to:
$ pacman -Fo /path/to/file_name
To list all packages no longer required as dependencies (orphans):
$ pacman -Qdt
To list all packages explicitly installed and not required as dependencies
$ pacman -Qet
Pactree
$ pactree package_name
Pactree: To view the dependency tree of a package
$ pactree package_name
Cleaning the package cache
# paccache -r