205

I'm looking for a package that provides a specific binary, so I can install it. how can I search to find out what packages provide this binary? (note: I know there's at least one tool that does this, but I have forgotten its name.)

2
  • Also the binary I'm looking for is /usr/sbin/ipset if someone wanted to tip me off on what package provides it even though they don't know the answer to the question. Commented Jun 12, 2011 at 14:59
  • Gilles answer is the correct one. Regarding ipset, I was only able to find it in AUR aur.archlinux.org/packages.php?ID=16553
    – jasonwryan
    Commented Jun 12, 2011 at 18:46

3 Answers 3

279

Since pacman 5.0, there is built-in functionality for searching the database with the -F option. First update the database:

sudo pacman -Fy

Then you can see which package contains $filename with

pacman -F $filename

if you are searching for an exact file name or full path, or

pacman -Fx $expr

to have $expr interpreted as a regular expression.

Since you knew you were looking for an equivalent of apt-file, you could have looked it up in the Pacman Rosetta.

Alternatively, you can use pkgfile. Install it with pacman -S pkgfile, then run

sudo pkgfile -u

to update the database. To see what package contains $filename, run

pkgfile $filename
3
  • 2
    Thanks for the Rosetta stone! I'll be using that for rpm distros as well as for pacman.
    – jpaugh
    Commented May 7, 2018 at 21:20
  • 1
    In pacman v5.2 this is now just pacman -F $filename. The -s flag has been removed. Commented Nov 18, 2019 at 19:35
  • pacman -F doesn't always seem to know. I have some files that I know what package they came/come from, but pacman -F fails on.
    – Thanatos
    Commented Jul 6, 2022 at 0:51
52

From ArchWiki:

$ pacman -Qo df

This will yield the owning package of the program df (at the time of writing, this is coreutils).

-Qo only operates on installed packages and their programs.

You can to see more arguments in querying package databases.

4
  • 12
    That only tells you what package owns a file, it won't tell you what you need to install to get it. Commented May 25, 2013 at 10:09
  • @DavidC.Bishop Is that not the very same thing?
    – Victor
    Commented May 1, 2014 at 0:19
  • 12
    @Victor No, the package must be installed on the system already in order to query it. Commented May 2, 2014 at 1:31
  • 1
    @DavidC.Bishop Ah I see, you meant "what installed package owns a fle". Thanks!
    – Victor
    Commented May 2, 2014 at 14:52
49

the google way:

site:www.archlinux.org/packages/ bin/filename

and in case it is in AUR instead of an official package:

site:aur.archlinux.org/packages/ bin/filename
1
  • 5
    Great tip, this seems to yield good results. I created a "search engine" in Chrome with this URL: https://www.google.com/search?q=site%3Awww.archlinux.org%2Fpackages%2F+%s. Commented Jul 5, 2018 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .