How to search for a package in Arch Linux

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.

ADVERTISEMENTS

How to search for a package with pacman?

The syntax is as follows for searching packages:
pacman -Ss {pkgNameHere}
pacman -Ss {keyWordHere}
pacman --sync --search packageName

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

extra/nmap 7.80-2
    Utility for network discovery and security auditing
community/dsniff 2.4b1-28
    Collection of tools for network auditing and penetration testing
community/lynis 2.7.5-2
    Security and system auditing tool to harden Unix/Linux systems
community/perf 5.7-1 (linux-tools)
    Linux kernel performance auditing tool
community/python-sqlalchemy-continuum 1.3.9-2
    Versioning and auditing extension for SQLAlchemy

Where,

  • -S, --sync : Synchronize packages. Packages are installed directly from the remote repositories, including all dependencies required to run the packages.
  • -s, --search : Search each locally-installed package for names or descriptions that match regexp. When including multiple search terms, only packages with descriptions matching ALL of those terms are returned.

How to search for a package with pkgfile?

The pkgfile command is nothing but a pacman ‘.files’ metadata explorer. First install pkgfile using the following syntax:
$ 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 21
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)
  -D, --cachedir     use an alternate cachedir (default: /var/cache/pkgfile)
  -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

Conclusion

You learned how to search packages in Arch Linux using the command line. See pacman man page for more information:
$ man pacman
$ man pkgfile

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • jonnyDev Aug 2, 2020 @ 16:30

    To search for package file names in remote packages:
    $ pacman -F str1 str2 str3 ...

  • Anonymous Sep 11, 2020 @ 18:23

    sudo pacman -Fy
    pacman -F

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.