Find out where package is installed

A few years ago, when I started to be a system administrator / DevOps engineer  I installed some package on a CentOS 7 system and I wanted to find out where all files were installed. I questioned myself if there is a way to ask the package manager where the package was installed. After some research, I found out the way and I will present you the result in this article.

I will split this article into two parts. In the first part I will talk about RHEL based Linux flavors by taking as example Centos 7 and in the second part I will take as example Ubuntu 18 for the Debian based Linux flavors.

Find out where a package is installed in CentOS

Yum is a very popular and frequently used package manager for this kind of Linux flavors. It is an interactive, open source, rpm based, package manager. It can perform a large variety of tasks that help you as a system administrator.

The syntax to install a package using yum is:

# yum install

Next, I will take as an example the xclip pachage. To install xclip on a Centos 7 you will need to do:

# yum install xclip

A simple way to find out where the package files were installed is:

# rpm -ql 

So, to find out where vim files were installed will need to run:

# rpm -ql xclip

Another way to find out where package were installed is to use repoquery.

# yum install yum-utils
# repoquery --list xclip

Find out where a package is installed in Ubuntu

The most popular package manager in Ubuntu systems is apt-get. As a beginner, when you install a piece of software using apt-get seems it is gone. If you want to find out where the package was installed you can use dpkg utility.

To install xclip on Ubuntu using apt-get:

# apt-get install xclip
# dpkg -S xclip
xclip: /usr/bin/xclip
x11-apps: /usr/share/man/man1/xclipboard.1.gz
xclip: /usr/bin/xclip-cutfile
xclip: /usr/share/man/man1/xclip-cutfile.1.gz
xclip: /usr/share/man/man1/xclip.1.gz
xclip: /usr/share/man/man1/xclip-copyfile.1.gz
x11-apps: /usr/bin/xclipboard
xclip: /usr/share/man/man1/xclip-pastefile.1.gz
xclip: /usr/bin/xclip-copyfile
xclip: /usr/share/doc/xclip/README
xclip: /usr/share/doc/xclip/changelog.Debian.gz
xclip: /usr/share/doc/xclip/copyright
xclip: /usr/share/doc/xclip
xclip: /usr/bin/xclip-pastefile

General ways

To find out these pieces of information you can use:

type -a
$ type -a xclip
xclip is /bin/xclip
xclip is /usr/bin/xclip
command -v
$ command -v xclip
$ which xclip

This commands should work on any Linux flavor.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)