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

How is Livepatch safeguarded against bad actors?

Canonical Livepatch is a security patching automation tool which supports reboot-less security updates for the…

5 hours ago

Accelerating data science with Apache Spark and GPUs

Apache Spark has always been very well known for distributing computation among multiple nodes using…

5 hours ago

Cut data center energy costs with bare metal automation

Data centers are popping up everywhere. With the rapid growth of AI, cloud services, streaming…

1 day ago

Build the future of *craft: announcing Starcraft Bounties!

Our commitment to building a thriving open source community is stronger than ever. We believe…

1 day ago

NodeJS 18 LTS EOL extended from April 2025 to May 2032 on Ubuntu

The clock was ticking: Node.js 18’s upstream End of Life (EOL) The OpenJS Foundation is…

1 day ago

Native integration now available for Pure Storage and Canonical LXD

June 25th, 2025 – Canonical, the company behind Ubuntu, and Pure Storage, the IT pioneer…

2 days ago