Categories: Ubuntu

How to Find a Package that Provides a File on Ubuntu

Finding a package that provides a file is important on Linux systems including Ubuntu. The reason is it helps users solve package dependency problems that occur when you install a package on the system and if a file is missing, you won’t be able to perform the installation until the file is found. Further, it also helps users debug server-related issues on the system that may fail to start if a required library is missing.

If you want to find a package that provides a file on Ubuntu, you should follow this article’s guidelines.

Find a Package that Provides a File on Ubuntu

Sponsored

There are two ways to find a package that provides a file in Ubuntu and those are:

Method 1: apt-file

The first method to find a package that provides a file is by using an apt-file package. The apt-file marks the indexes for all installed packages which are present in the repository. By using apt-file, the users can search for a file provided by any of the packages present inside the repository, and this all searching process completes within a few seconds. This method is divided into two parts which are:

i: Installing apt-file

To install “apt-file” on your Ubuntu system, firstly update and upgrade the repository:

sudo apt update
sudo apt upgrade

 
Then install apt-file by using the below-mentioned command:

sudo apt install apt-file

 

The apt-file access database to find the packages belonging to a package and for that reason, it is important to update apt-file through the following command before searching for a file on Ubuntu:

sudo apt-file update

 

ii: Searching File Using apt-file

To search the file using apt-file, run the below-mentioned command along with the name of the file:

apt-file search filename>

 
For example:

apt-file search hippo_opensim_viewer.xml

 

Or you can also use the file path to directly navigate the file, and its associated package:

apt-file search file-path>

 
For example;

apt-file search /usr/share/bleachbit/cleaners/hippo_opensim_viewer.xml

 

Sponsored

Method 2: By Using dpkg

The other method to find a package that provides a file is by using the dpkg command, which is used to find the packages that were installed without a repository that is what makes it unique from apt-file. But dpkg can only list the files of packages which are installed in the system, whereas apt-file can even list the packages which are not installed in the system but are present in the repository.

Use the below-written dpkg file along with -S identifier for search, to find the package associated with the desired file:

dpkg -S filename>

 
For example:

dpkg -S libsnapd-glib.so.1

 

Just like apt-file, you can also use a file path instead of just file name with the dpkg command to property navigate the file from its directory:

dpkg -S path>

 
For example;

dpkg -S /usr/lib/x86_64-linux-gnu/libsnapd-glib.so.1

 

Bonus Tip

The dpkg command can also be used to search all the packages present inside a directory or library by using the below-mentioned command:

dpkg -S Directory>

 
For instance, here I have displayed all the packages present inside the /var/lib:

dpkg -S /var/lib

 

Conclusion

To find a package that provides a file on Ubuntu, there are two ways: One is by using the “apt-file” tool which uses the database to search the file from the list of packages present inside the repository. The other method is by using the dpkg -S command to search the file from the list of installed packages. The apt-file tool needs to be installed, whereas “dpkg” is already present by default in Ubuntu.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

5 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago