How to search for a package with pacman?

I just installed Archlinux and want to install netstat. However using the command pacman -Ss netstat outputs irrelevant package names. A search on internet revealed that netstat is owned by net-tools. Installing net-tools gave me access to netstat.

How should one proceed to find the package name to install with pacman when only the final bash command is known ?

Asked By: ChiseledAbs

||

The best way that I have found until now is to use the pkgfile command.
You could install it by:

# sudo pacman -S pkgfile

according to the official arch wiki,

pkgfile is a tool for searching files from packages in the official repositories.

(files being the binaries you mentioned as bash commands).

You can also update its database by running:

# pkgfile -u

or you could just enable its systemd timer for it to update automatically:

# systemctl enable pkgfile-update.timer
# systemctl start pkgfile-update.timer

awsome, right ?! 🙂

Example

# pkgfile netstat
core/net-tools
extra/munin-node

# pkgfile netstat --verbose
core/net-tools 1.60.20160710git-1       /usr/bin/netstat
extra/munin-node 2.0.26-2               /usr/lib/munin/plugins/netstat
Answered By: pouya
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.