How to search for a package in Arch Linux

Posted on in Categories , , last updated May 9, 2017

I am a new Arch Linux user. How do I search the repository for installable packages under Arch Linux using command line option?

You can use pacman or pkgfile command to search for a package in Arch Linux using a bash shell prompt.

How to search for a package with pacman?

The syntax is:
pacman -Ss {pkgNameHere}
pacman -Ss {keyWordHere}

For example, search for nmap, type pacman command:
$ pacman -Ss nmap
OR
$ pacman -Ss auditing
Sample outputs:

extra/nmap 7.40-2
    Utility for network discovery and security auditing
community/dsniff 2.4b1-26
    Collection of tools for network auditing and penetration testing
community/lynis 2.4.8-1
    Security and system auditing tool to harden Unix/Linux systems
community/perf 4.11-1 (linux-tools)
    Linux kernel performance auditing tool

How to search for a package with pkgfile?

The pkgfile command is nothing but a pacman .files metadata explorer. First install pkgfile, enter:
$ sudo pacman -S pkgfile
Sample outputs:

Fig.01: Installing pkgfile on Arch Linux
Fig.01: Installing pkgfile on Arch Linux

Type the following command to update index:
$ sudo pkgfile --update
Sample outputs:

:: Updating 3 repos...
  download complete: core                 [   693.9 KiB   208K/s  2 remaining]
  download complete: extra                [     7.1 MiB   807K/s  1 remaining]
  download complete: community            [    15.5 MiB  48.6K/s  0 remaining]
:: download complete in 325.94s           <    23.2 MiB  73.0K/s  3 files    >
:: waiting for 1 process to finish repacking repos...

Simple search

Type the command:
$ pkgfile nginx
$ pkgfile php
$ pkgfile nmap

Sample outputs:

extra/bash-completion
extra/nmap

How do I display files provided by a remote package i.e. uninstalled package?

The syntax is
$ pkgfile -l packageName
$ pkgfile -l nmap
$ pkgfile -l bash

Sample outputs:

core/bash	/etc/
core/bash	/etc/bash.bash_logout
core/bash	/etc/bash.bashrc
core/bash	/etc/skel/
core/bash	/etc/skel/.bash_logout
core/bash	/etc/skel/.bash_profile
core/bash	/etc/skel/.bashrc
core/bash	/usr/
core/bash	/usr/bin/
core/bash	/usr/bin/bash
core/bash	/usr/bin/bashbug
core/bash	/usr/bin/sh
core/bash	/usr/include/
core/bash	/usr/include/bash/
core/bash	/usr/include/bash/alias.h
core/bash	/usr/include/bash/array.h
core/bash	/usr/include/bash/arrayfunc.h
core/bash	/usr/include/bash/assoc.h
....
...
....
core/bash	/usr/share/locale/zh_CN/LC_MESSAGES/
core/bash	/usr/share/locale/zh_CN/LC_MESSAGES/bash.mo
core/bash	/usr/share/locale/zh_TW/
core/bash	/usr/share/locale/zh_TW/LC_MESSAGES/
core/bash	/usr/share/locale/zh_TW/LC_MESSAGES/bash.mo
core/bash	/usr/share/man/
core/bash	/usr/share/man/man1/
core/bash	/usr/share/man/man1/bash.1.gz
core/bash	/usr/share/man/man1/bashbug.1.gz

To see a list of files provided by local package, use:
$ pacman -Ql bash

How do I perform matching with regular expressions?

The syntax is:
$ pkgfile -r regex
$ pkgfile -r php*
$ pkgfile -r nginx*

See all other options

The syntax is:
$ pkgfile -h

pkgfile 17
Usage: pkgfile [options] target

 Operations:
  -l, --list              list contents of a package
  -s, --search            search for packages containing the target (default)
  -u, --update            update repo files lists

 Matching:
  -b, --binaries          return only files contained in a bin dir
  -d, --directories       match directories in searches
  -g, --glob              enable matching with glob characters
  -i, --ignorecase        use case insensitive matching
  -R, --repo        search a singular repo
  -r, --regex             enable matching with regular expressions

 Output:
  -q, --quiet             output less when listing
  -v, --verbose           output more
  -w, --raw               disable output justification
  -0, --null              null terminate output

 Downloading:
  -z, --compress[=type]   compress downloaded repos

 General:
  -C, --config      use an alternate config (default: /etc/pacman.conf)
  -h, --help              display this help and exit
  -V, --version           display the version and exit

A note about CentOS/Red Hat Enterprise Linux users

Use the following yum command
$ yum search pkgName
$ yum search php

A note about Fedora Linux users

Use the following dnf command
$ dnf search pkgName
$ dnf search php

A note about Debian/Ubuntu Linux users

Use the following apt command
$ apt search pkgName
$ apt search php

A note about Suse/OpenSuse Linux users

Use the following zypper command
$ zypper search pkgName
$ zypper search php

A note about Alpin Linux users

Use the following apk command
$ apk search pkgName
$ apk search php

A note about Gentoo Linux users

Use the following emerge command
$ emerge -S pkgName
$ emerge -S pkgName

Leave a Comment