How to know which package a certain file belongs to

Has it ever happened to you that you couldn't build a package because there was a missing dependence? A similar situation can occur when we want to compile a program or run a binary. In these cases, we may run into an error such as: «X file is missing, impossible to perform the requested task«.

Or worse: how to fix the classic dependency conflict: "file X is already installed«? For this it is necessary to discover which package contains the file in question. How to do it? Ha! Come in and find out ...


A while ago we saw how to do it on Debian, Ubuntu and derivatives. Now, let's see how it is done in the rest of the distros as well.

APT: Debian, Ubuntu and derivatives

Those distros that use APT, can use apt file.

sudo apt-get install apt-file

Once installed, it runs like this:

apt-file search / path / file

Where / path / file is the path of the file you are looking for.

RPM: Red Hat, Fedora and derivatives

You only need to execute the following command:

rpm -qf / path / file

Where / path / file is the path of the file you are looking for.

Pacman: Arch and derivatives

In Arch, you only need to use the almighty Pacman:

pacman -Qo / path / file

So, for example, the command:

pacman -Qo /usr/lib/gtk-2.0/2.10.0/engines/libmist.so

Bring back:

/usr/lib/gtk-2.0/2.10.0/engines/libmist.so is owned by gtk-engines 2.20.2-1

It is also possible to use pkgfile. You only need to install it:

pacman -S pkgtools

It runs like this:

pkgfile file

Where file is the name of the file you are looking for.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Miguel Chan said

    Come on, it comes to me from ten (the knack of compiling) !!! Thanks and greetings !!!

  2.   Let's use Linux said

    You're welcome Migue! I'm glad it works.
    A hug! Paul.

  3.   joadelvia said

    Good contribution. In Debian, Ubuntu and derivatives, you can also use the dpkg command with the -S option to get the same information, in case you don't want to install apt-file. Using it would be very similar to apt-file:
    dpkg -S / path / file

    1.    let's use linux said

      Interesting! Thanks for the contribution!
      Hug! Paul.