Skip to content

How to find which package provides a file

Use this guide in either of two situations:

  • A file exists on the system, such as a command, a library or a configuration file, and you need to know which package installed it, for example to reinstall it, read its documentation or report a bug.
  • A command or file you need is missing, and you need to know which package to install to get it.

Before you begin

  • You need a shell on the machine. Searching for files in packages that aren't installed needs sudo the first time, to download the file lists.
  • Replace <FILE> with the absolute path of the file, for example /usr/bin/lsblk.

Find the package that owns an installed file

  1. If you only know a command's name, find its path first:

    $ command -v lsblk
    /usr/bin/lsblk
    
  2. Ask the package database which package owns the file:

    $ dpkg -S <FILE>
    util-linux: /usr/bin/lsblk
    

    dpkg matches the path as it is recorded in the package, not as it resolves on disk. On Debian 13 and Ubuntu 26.04, /bin is a symbolic link to /usr/bin and packages record their files under /usr, so dpkg -S /bin/lsblk reports no path found matching pattern. Resolve the path first if that happens:

    $ dpkg -S "$(readlink -f /bin/lsblk)"
    util-linux: /usr/bin/lsblk
    

    Given a name instead of a path, dpkg -S lists every installed file whose path contains it, which is useful when you know only part of the name.

    $ rpm -qf <FILE>
    util-linux-2.40.2-18.el10.x86_64
    

    Add --qf '%{NAME}\n' to print only the package name.

    $ pacman -Qo <FILE>
    /usr/bin/lsblk is owned by util-linux 2.42.4-1
    

    qfile from app-portage/portage-utils reads Portage's installed-package database directly. Gentoo records each file under the path its package installed it to, which on a merged-/usr system is often still /bin or /sbin. qfile /usr/bin/lsblk therefore prints nothing, while the recorded path works:

    $ qfile /bin/lsblk
    sys-apps/util-linux: /bin/lsblk
    

    Given only a file name, qfile matches it in any directory, which avoids the problem but can list several files:

    $ qfile lsblk
    sys-apps/util-linux: /usr/share/bash-completion/completions/lsblk
    sys-apps/util-linux: /bin/lsblk
    

    equery belongs, from app-portage/gentoolkit, answers the same question with the same path rules.

  3. If the command reports that no package owns the file, the file wasn't installed by the package manager. Common reasons are software installed by hand under /usr/local or /opt, files generated at installation or boot time (for example /etc/hostname or /etc/machine-id), and files created by an administrator.

Find the package that provides a missing file

This needs a list of the files in every package in the repositories, not only the installed ones. The example looks for the dig DNS lookup command.

  1. Install apt-file and download the file lists for the configured repositories:

    sudo apt-get update
    sudo apt-get install -y apt-file
    sudo apt-file update
    
  2. Search for the path. apt-file search matches any path that contains the pattern; -x treats it as a regular expression, which lets you match the end of the path exactly:

    $ apt-file search -x '/usr/bin/dig$'
    bind9-dnsutils: /usr/bin/dig
    

On Ubuntu, typing a missing command in an interactive shell also prints the package that provides it, through the command-not-found package.

dnf downloads file lists with the repository metadata, so no extra tool is needed. Give it the full path, or a glob such as '*/dig' when you don't know the directory:

$ dnf provides /usr/bin/dig
bind-utils-32:9.18.33-15.el10_2.1.x86_64 : Utilities for querying DNS name servers
Repo        : appstream
Matched from:
Filename    : /usr/bin/dig

dnf lists every version in the repositories that contains the file; the package name is what you install (here bind-utils).

  1. Download the file databases for the configured repositories:

    sudo pacman -Fy
    
  2. Search for the path or for a file name:

    $ pacman -F /usr/bin/dig
    usr/bin/dig is owned by extra/bind 9.20.30-1
    

    Given only a name, pacman -F dig lists every package with a file of that name in any directory.

The file databases aren't refreshed by pacman -Syu; run sudo pacman -Fy again before searching if they're old.

Gentoo has no index of the files that uninstalled packages would install, because the files depend on how each package is built (its USE flags). Search the ebuild repository by package name or description instead, starting from what the command is part of: dig is part of BIND. A leading % makes the search term a regular expression:

$ emerge --search '%^bind$'
*  net-dns/bind
      Latest version available: 9.20.30
      Latest version installed: [ Not Installed ]
      Size of files: 5,864 KiB
      Homepage:      https://www.isc.org/bind/
      Description:   Berkeley Internet Name Domain - Name Server
      License:       MPL-2.0

emerge --searchdesc (-S) also searches the descriptions. Results marked [ Masked ] aren't installable as they are; net-dns/bind-tools, for example, is masked, and dig is now installed by net-dns/bind. The package app-portage/pfl provides e-file, which queries a community-run online index of the files in Gentoo packages; it isn't covered here.

Verify

Install the package you found and check that the file now exists and belongs to it:

sudo apt-get install -y bind9-dnsutils
dpkg -S /usr/bin/dig
sudo dnf install -y bind-utils
rpm -qf /usr/bin/dig
sudo pacman -S --needed --noconfirm bind
pacman -Qo /usr/bin/dig
sudo emerge --getbinpkg net-dns/bind
qfile dig

Troubleshooting

apt-file search prints nothing
The file lists haven't been downloaded, or are for different repositories than you expect. Run sudo apt-file update again after changing repositories. Check that the path is spelt as packages install it: under /usr/bin, not /bin, on Debian 13 and Ubuntu 26.04.
dnf provides reports No matches found
The file isn't in any enabled repository. A disabled repository may provide it. On Rocky Linux, the CRB repository is disabled by default (on AlmaLinux 10 it's enabled); dnf --enablerepo=crb provides <FILE> also searches it, without enabling it permanently.
pacman -F reports error: no file databases or finds nothing
The file databases were never downloaded, or are out of date. Run sudo pacman -Fy.
The file is provided by more than one package
This is normal for alternatives such as vi, editor or mail transfer agents. Pick the package from the distribution's documentation for the feature you want. To see which installed program currently provides a generic name such as editor, run update-alternatives --display <NAME> on Debian and Ubuntu or alternatives --display <NAME> on the RHEL family, where <NAME> is the generic name; it shows the path of the selected program, and dpkg -S or rpm -qf on that path shows its package.