Short Tip: Searching files and packages

In case you ever compiled anything by hand you might have gotten an error message like this:

make[2]: *** No rule to make target `/lib/', needed by `lib/'.  Stop.
make[1]: *** [config/CMakeFiles/kstyle_qtcurve_config.dir/all] Error 2
make: *** [all] Error 2

There is obviously a file missing, in this case to compile a specific KDE 4 theme. There are now two ways of searching for the package which contains the file: either through the command line, or through an online package database.

The command line of course depends on the used package manager, here are some examples:

apt-file -x search*
yum whatprovides*
zypper wp

The -x in case of apt-file makes it possible to use regular expressions. Except for zypper all commands above can be used with regular expressions or show matches if the searched expression is only part of a result (like

The package databases depend again on the distribution, but at least for the rpm based distributions there is one common place: Especially the advanced link is of interest since the results can be filtered by distribution and distribution version.
For Ubuntu based distributions there is the Ubuntu package database, but make sure you use the second entry field. Unfortunately, the database only supports the right file names. Searching for libacl will bring you zero results – which is, to be honest, quite stupid. Gentoo users can try

I am well aware that each distribution has again its own database – but that’s not handy if you deal with different distributions each day. If you now more commands for other distribution tools or other central databases for file/package searches, please leave a comment and I will add them.


19 thoughts on “Short Tip: Searching files and packages”

  1. And there is obviously a proper test for the existence of libacl in the cmake files missing.
    Something like
    find_library(ACL_LIBRARY acl)
    message(FATAL_ERROR “libacl not found”)
    endif(NOT ACL_LIBRARY)


  2. For gentoo:
    equery b (app-portage/gentoolkit)
    but of course it will not find libs which are not installed on system. And don’t forget about revdep-rebuild

  3. openSUSE >=11.0:

    zypper wp
    zypper –what-provides

    all openSUSE:
    start yast -i, tick “provides” and search for “”

  4. dBera, does urpmf support asterisks, like urpmf* ? And the mentioned web address is a distribution specific, and therefore is not interesting since offers more.

    inful, thx – still, I wonder why to add the -x…

    Alex, yes, of course, but as the result cmake would tell you that libacl is missing, and you still have to install it 😉

    Thomas, non7top: does equery only support installed files, or also general available files? Because I’m focussing on the second case here. Besides, does it support regular expressions? And since I am not a Gentoo user, what is about revdep-rebuild?

    Robin, thanks for the zypper hint, I was wondering if that is possible with zypper. Any idea how to teach zypper regular expressions?

  5. @liquidat:
    zypper supports patterns when searching, i.e.:

    zypper se *zypp*

    regex is not supported nor planned afaik.

    zypper wp /–what-provides doesn’t support patterns, at least it gave me an error when I tried it. Dunno if this should work (maybe file a bug report for it)

  6. Smarter, you are of course right – but then again, the search must (!) be specified for a specific distribution version. I don’t get it why I can’t have both.

    Robin, thx for the hint, but unfortunately zypper se ** doesn’t result in packages containing files.

  7. liquidat, that’s because zypper se (search) does not search for dependencies but only for package names (or descriptions if called with “-d”.
    only zypper wp (what-provides) searches for rpm-“provides”

  8. liquidat, to answer your question to dBera about urpmf, I found this in the manpage of urpmf : “Perl-style regular expressions are allowed.”

  9. > Thomas, non7top: does equery only support installed files, or also general available files? Because I’m focussing on the second case here. Besides, does it support regular expressions?

    Equery does the first class. The reason is that Portage (Gentoo’s package manager) cannot account for all of the installable files in advanced, since it compiles all of the applications, and different compiler options may result in different files.

    > And since I am not a Gentoo user, what is about revdep-rebuild?
    Again, since everything is compiled, upgrades may break other packages. revdep-rebuild scans all of the installed libraries and programs for broken dynamic linking, and recompiles when it finds it.

  10. This one should work on all RPM-based systems (and much faster than the package managers on top of it): rpm -q –whatprovides

  11. Stefan, that only works for installed files – and is therefore totally useless when you want to search for packages of files which are *missing*.

    hrongyorgy, thx.

  12. Mandriva rocks. You don’t have to install the external apt-file package, that should really be part of debian base … urpmf does everything for you.

  13. Benjamin, the commands above give examples for the various different distributions. So of course for Mandriva you use urpmf, while on Debian you use something apt-based.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s