Home FAQ How To List The Contents Of A Package In Linux

We already knew how to list installed packages and also how to list the dependencies of a package in Linux. Today, we will see how to list the contents of a package in Linux. It doesn't matter whether the package is installed or not. It is possible to read the contents of an installed or non-installed package.

In Linux and Unix, most programs don't usually end up in a single directory. When you install a package, all the files in that package are scattered through filesystem and saved in different paths. Usually, the executable files (e.g. the binaries/scripts) are stored in '/bin' or '/usr/bin' or '/usr/local/bin' directories, library files in '/usr/lib', configuration files in '/etc', static data in '/usr/share', and so on. Now let us find the list of files in a package and where are they actually stored in Linux.

List The Contents Of A Package In Linux

First, we will see how to read the contents of a package in DEB-based systems, for example Ubuntu.

List the contents of an installed package in Ubuntu

I already have installed Microsoft Teams package in my Ubuntu 20.04 desktop.

To view the contents of the Microsoft Teams package, simply run:

$ dpkg -L teams

Sample output:

/.
/usr
/usr/bin
/usr/bin/teams
/usr/share
/usr/share/applications
/usr/share/applications/teams.desktop
/usr/share/pixmaps
/usr/share/pixmaps/teams.png
/usr/share/teams
.
.
.

/usr/share/teams/swiftshader/libEGL.so
/usr/share/teams/swiftshader/libGLESv2.so
/usr/share/teams/teams
/usr/share/teams/v8_context_snapshot.bin

List the contents of an installed package in Ubuntu

See? The above output shows the files installed by the Teams package and their location in my Ubuntu system.

Here is another way to view the contents of an installed package in Ubuntu:

$ dpkg-query -L teams

List the contents of a non-installed package in Ubuntu

Like I already said, the above commands displays the contents of an installed package. What if the package is not installed and you want to read its contents? It is possible too! You can find which files will be installed by a package even before installing it.

First download the .deb file. I have already download the Teams application .deb file. Go to the location where you have downloaded the .deb file and run the following command to view its contents:

$ dpkg --contents teams_1.2.00.32451_amd64.deb

Or,

$ dpkg -c teams_1.2.00.32451_amd64.deb

Sample output:

drwxr-xr-x root/root         0 2019-11-20 20:55 ./
drwxr-xr-x root/root         0 2019-11-20 20:54 ./usr/
drwxr-xr-x root/root         0 2019-11-20 20:54 ./usr/bin/
-rwxr-xr-x root/root       286 2019-11-20 20:54 ./usr/bin/teams
drwxr-xr-x root/root         0 2019-11-20 20:54 ./usr/share/
drwxr-xr-x root/root         0 2019-11-20 20:54 ./usr/share/applications/
-rw-r--r-- root/root       352 2019-11-20 20:54 ./usr/share/applications/teams.desktop
.
.
.
-rwxr-xr-x root/root    286264 2019-11-20 20:54 ./usr/share/teams/swiftshader/libEGL.so
-rwxr-xr-x root/root   2677296 2019-11-20 20:54 ./usr/share/teams/swiftshader/libGLESv2.so
-rwxr-xr-x root/root 114944384 2019-11-20 20:54 ./usr/share/teams/teams
-rw-r--r-- root/root   1040824 2019-11-20 20:54 ./usr/share/teams/v8_context_snapshot.bin

List the contents of a non-installed package in Ubuntu

Alternatively, you can do this using apt-file tool as well.

Install apt-file as shown below if it’s not installed already:

$ sudo apt install apt-file

If you just installed apt-file, the system-wide cache might be empty. You need to run ‘apt-file update’ as root to update the cache. You can also run ‘apt-file update’ as normal user to use a cache in the user’s home directory.

Let us update the database cache using command:

$ sudo apt-file update

Now list the contents of a installed package, for example vim, like below:

$ apt-file list vim

Sample output:

vim: /usr/bin/vim.basic 
vim: /usr/share/bug/vim/presubj
vim: /usr/share/bug/vim/script
vim: /usr/share/doc/vim/NEWS.Debian.gz
vim: /usr/share/doc/vim/changelog.Debian.gz
vim: /usr/share/doc/vim/copyright
vim: /usr/share/lintian/overrides/vim

List the contents of a installed package using apt-file command

The apt-file tool is also used to search for the packages that provides a specific file. For example, find the package that provides alisp.h file with command:

$ apt-file find alisp.h

Or,

$ apt-file search alisp.h

Sample output:

libasound2-dev: /usr/include/alsa/alisp.h

As you can see, the "libasound2-dev" package provides the alisp.h file.

For more details, refer the following link.

These are a few ways to view the contents of a package in DEB-based systems. Now let see how to list the package contents in RPM-based systems, for example CentOS.

List the contents of an installed/non-installed package in CentOS

In RPM-based systems like CentOS, we can find the contents of a package using "repoquery" command.

The "yum-utils" package provides repoquery command, so let us install it using command:

$ sudo yum install yum-utils

Now let us find out the contents of "nano" editor package using command:

# repoquery --installed --list nano

Or,

# repoquery --list nano

Or,

# repoquery -l nano

Sample output:

Last metadata expiration check: 0:03:02 ago on Tuesday 16 June 2020 06:01:46 PM IST.
/etc/nanorc
/usr/bin/nano
/usr/bin/rnano
/usr/lib/.build-id
/usr/lib/.build-id/d3
.
.
.
/usr/share/nano/tcl.nanorc
/usr/share/nano/tex.nanorc
/usr/share/nano/texinfo.nanorc
/usr/share/nano/xml.nanorc

List the contents of an installed package in CentOS

The same way you can list the contents of a non-installed file. Go to the location where you downloaded the rpm file and view its contents like below:

# repoquery --list nano-2.9.8-1.el8.x86_64.rpm

Related read:

Hope this helps.

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More