How to Tell the Package Name Contains A Specific File in Ubuntu / Linux Mint

Miss a shared library when running an application, or want to know which package to install for a specific file? Well, let me show you how to find it out with 3 ways in Ubuntu, Debian, Linux Mint, and their derivatives.

Option 1: Search which package provides a file within installed packages.

The dpkg command line package manager has a -S (or --search) option to search for an installed file in your system.

You can simply run command dpkg -S FILE_NAME in terminal or command console.
It will output all possible files that contain ‘FILE_NAME’ in their names, and show you which packages provide them.

For example, when I’m searching for ‘clnt.h‘ via command:

dpkg -S clnt.h

It outputs something like the picture shows:

If you know the path to your file, run dpkg -S /PATH/TO/FILE_NAME instead to get more accurate outputs.

In the case, I uses ‘/usr/include/tirpc/rpc/clnt.h‘ in the command:

dpkg -S /usr/include/tirpc/rpc/clnt.h

And it outputs that libtirpc-dev provides the file.

Option 2: Search which package provides a file from both installed / non-installed packages in system repositories.

There’s an apt package searching utility called apt-file allows you to easily search for a file through system repositories and installed third-party repositories.

1. First install apt-file, if you don’t have it, by running command:

sudo apt install apt-file

2. Then run command to update the database before using the utility:

sudo apt-file update

3. You can finally run command apt-file search FILE_NAME to search a file.

For example, the command below will tell the ‘libmpv1’ package offers ‘libmpv.so.1’ library.

apt-file search libmpv.so.1

Option 3: Search a file via Ubuntu website.

For Ubuntu users, there’s an easier way that you can simply go to packages.ubuntu.com.

Scroll down a little, and type a keyword to search contents of packages.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.