How to Check Dependencies for Package in Linux

How to Check Dependencies for Package in Linux

Most Linux packages depend on other packages and modules for their proper functioning. They are not known as package dependencies. Before you install a package, it is important to check its dependencies. Some packages require too many dependencies that take up a lot of disk space. In such cases, it is better to go with an alternative. Also, in some cases, updating a dependency may break some of your other packages which also have the same dependency. In this article, we will learn how to check dependencies for Linux package.

How to Check Dependencies for Package in Linux

There are several ways to check dependencies for Linux packages. In all cases, you need to correctly mention the package name, otherwise you may not get required information.

1. Apt Show

You can use ‘apt show’ command to quickly get package dependencies. Here is its syntax.

$ apt show package_name

Here is an example to get package dependencies for Apache server.

$ apt show apache2

You will see many lines of output. Among them, look for the one starting with ‘Depends:’.

...
Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.29-1ubuntu4.16), apache2-utils (= 2.4.29-1ubuntu4.16), apache2-data (= 2.4.29-1ubuntu4.16), perl:any
...

2. Apt-Cache

You can also use apt-cache command to easily get the package dependencies. Here is its syntax.

$ apt-cache depends package_name

Here it the command for getting package dependency of Apache server.

$ apt-cache depends apache2

Here is its output. It not only displays dependencies but also conflicts and suggestions.

apache2
PreDepends: dpkg
Depends: lsb-base
...
Conflicts: <apache2.2-bin>
Conflicts: <apache2.2-common>
...
Recommends: ssl-cert
Suggests: apache2-doc
...
Replaces: <apache2.2-bin>
Replaces: <apache2.2-common>

3. Using dpkg

You can also use dpkg command to get details of a downloaded package before installation, as shown.

pkg --info [deb_file_path]

Here is the command to check dependencies for package in Linux.

dpkg --info Downloads/teamviewer_15.16.8_amd64.deb

In this article, we have learnt several ways to check dependencies of a package. These tools are available by default in every Linux. Please note, ‘apt show’ and ‘apt-cache’ commands allow you to check package dependencies before installation whereas dpkg allows you to check them only after you have downloaded its file but not installed it yet.

You can use any of the above tools, as per your requirement.

Also read:

How to Install Specific Version of NPM Package
How to Disable GZIP Compression in Apache
How to Disable TLS 1.0 in Apache
Shell Script to Automate SSH Login
How to Force User to Change Password in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *