Packages and repositories are the bread and butter of Linux operating systems. The first step to installing any software on a Linux-based system is to download its package from its respective repository. A package refers to a compressed archive that contains all the files required for a piece of software to execute properly. Typically, packages are downloaded from their corresponding repositories. Common formats of Linux packages include .deb, .rpm and .tgz. This article will learn about various methods to find out what files are included in Linux packages.
Method 1 – Checking files online
Let’s start with the simplest and most user-friendly method to find what files are included in a Linux package. The first step is to visit this link and to use the website, as we demonstrate in the following steps. This method does not require any command-line expertise or installing any external utilities. You can find out the list of files of a package by following these steps:
- Open the http://packages.ubuntu.com/ website in a web browser of your choice.
- Scroll down to ‘Search package directories’.
- Type your package name in the keyword field.
- Check the ‘Show exact matches’ box.
- Select your distribution.
- Press the ‘Search button.
- Specify your architecture and the desired package on the next page.
- Click on ‘list of files’ next to your architecture to get the list of the files in the specific package.
And with that done, you can check out any package and look at what’s inside it. Along with this cool feature, the website also allows users to search for specific files. Then, of course, you can learn more about them through their documentation.
Method 2 – Using dpkg
Dpkg is a tool for building and managing packages in Linux. We can also use it to list the files contained in a package in Ubuntu. Moreover, dpkg can be used for searching a particular file and see which packages use it. Interestingly, dpkg is the main command that plays the role of installing and removing programs on your Linux system. The more commonly known and used apt-get and other similar commands just call dpkg to get the same results. So basically, while using dpkg, you are operating at the very low-level base of the operations. Now, with the essential details out of the way, let us go back to our main concern – using dpkg to determine what files are in a package.
The first step is to open a terminal in Ubuntu. You can either access it through the applications menu or press the shortcut Ctrl + Alt + T.
To list the files of an installed package, we can execute the following command (the ‘$dpkg’ is the name of the package for which the list of files is required)
You can find out which a .deb package will install files through the following simple dpkg command.
However, our main course of action in this tutorial is to show you how you can check the files in a package that is not even installed yet. Worry not, as the small command is given below will do just that.
This command shows the same output as the previous attached image. However, this one would work for packages that are not already installed as well.
As we mentioned earlier, dpkg also allows you to search for a particular file and find which packages contain that file. This functionality can be utilized by appending -S (search flag) with dpkg:
cairo.h is the filename we are looking for. If you know the address of the particular file that you are looking for, you can include it in the command to narrow down the results.
One of the major advantages of using dpkg is that it can be used with packages that are not installed from any repositories.
Method 3 – Using apt-file
apt-file is a Linux package that can list the files contained in a package or search through the package for a particular filename. apt-file can be used to find files of a package that is not installed as well.
First, open a terminal through the application menu or by pressing the shortcut Ctrl + Alt + T.
Before we proceed any further, we first have to install the apt-file package itself. You can do that by running the command given below.
apt-file searches a database to look for packages and their files. It is good practice to update the database before moving on with the search.
Now that everything is up and running, we initiate the search for our required packages. This can be done through the following command.
If you want to search for a particular filename (cairo.h in our case), you can use the command below.
As was the case with dpkg, if you know the address of the file you are searching for, you can specify that too narrow down the search results.
That about covers all there is to using apt-file to find files in a package. However, if you wish to use apt-file to benefit further, the following help commands are for you.
$ apt-file --help
In this article, we have gone through various methods to get a list of the files in a package. Whether you prefer searching with GUI-based online resources or comfortable with the command-line interface, now you know how to get a list of files of any available package.