Linux distributions contain many packages that are used for different purposes in daily life and these packages contain different files, including configuration files, executable files, and dependency files. All these packages are included in the repository of Linux distribution and can be installed using any package manager.
In this article, we are going to discover different types of techniques by which we can find out the packages in which a specific file is included.
How to find which package contains a specific file on Ubuntu?
There are a lot of packages in the Ubuntu repository and a great number of files that these packages contain, so it looks very difficult to find out the specific file.
The two methods to find packages containing specific files are:
- Checking files online for Ubuntu 22.04
- Installing apt-file on Ubuntu 22.04
Method 1: Checking files online for Ubuntu 22.04
The first and very convenient method of finding packages is to search online by visiting the home page of Ubuntu packages using this link.
Open the link mentioned in the favorite browser of Ubuntu:
A page similar to the above will be opened in the browser, scroll down the page, and you will find the search bars as shown below:
Here, first select the version of Ubuntu, like we chose “jammy”, type the name of the file e.g. “libprcre.so” in the keyword section as mentioned above, and click on the “Search” button:
In the search results, you will find all the packages containing that specific file. For example, we searched for “libprcre.so”, so in the results, all the packages displayed which contain this file with the file path.
Method 2: Installing apt-file on Ubuntu 22.04
Another method to search for specific file in a package is to use “apt-file” application. It is available in Ubuntu’s Official repository and can be installed using the command typed below:
$ sudo apt install apt-file -y
When the package of apt-file has been installed, we need to update the apt-file once, using the command:
$ sudo apt-file update
We can use the apt-file to search packages, and for this purpose, the general syntax of using the apt-file to search packages is:
To search for a package including specific file, following syntax is used:
$ sudo apt-file search -i [file name]
In the above command, just replace the “[file name]” with the file name whose packages you want to search, e.g. “libprcre.so”:
$ sudo apt-file search -i 'LibPcre.so'
The command will display the packages that are containing the specific file “libpcre.so”.
Ubuntu contains hundreds of packages that contain further a lot of files, so if you are interested in finding packages by some specific file, then this article is best for you. We have discussed two different methods of finding packages by using a specific file name.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY