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 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:
$ 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, --cachediruse 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
🐧 2 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
To search for package file names in remote packages:
$ pacman -F str1 str2 str3 ...
sudo pacman -Fy
pacman -F