Dependencies are other Linux packages & libraries that need to be installed or present on your system, before you can install any package. Sometimes you may need to check dependencies of Linux package before installing it. It is because some packages have too many dependencies that take up a lot of disk space and it might be advisable to look for an alternative. There are many simple ways to list the various dependencies of any Linux package. In this article, we will look at how to check dependencies for package in Linux.
How to Check Dependencies for Package in Linux
Here are the different ways to check dependencies for package in Linux. In each of the following cases, it is important to mention the correct name of your package to get the right information. Otherwise you may get required information. For example, you need to mention apache2 and not apache, as shown below, if you want to find out dependency information about Apache web server.
1. Using Apt Show
You can easily list use apt show command to get complete details of a package, including its dependencies. Here is its syntax.
$ sudo apt show [package_name]
Here is an example.
$ sudo apt show apache2
Here is the output with the dependencies mentioned in depends section highlighted in bold.
Package: apache2 Version: 2.4.29-1ubuntu4.16 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers <email@example.com> Original-Maintainer: Debian Apache Maintainers <firstname.lastname@example.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 536 kB Provides: httpd, httpd-cgi Pre-Depends: dpkg (>= 1.17.14) 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 Recommends: ssl-cert Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw Conflicts: apache2.2-bin, apache2.2-common Replaces: apache2.2-bin, apache2.2-common Homepage: http://httpd.apache.org/ Task: lamp-server Supported: 5y Download-Size: 95.1 kB APT-Manual-Installed: no APT-Sources: http://us-west-2.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages Description: Apache HTTP Server The Apache HTTP Server Project's goal is to build a secure, efficient and extensible HTTP server as standards-compliant open source software. The result has long been the number one web server on the Internet. . Installing this package results in a full installation, including the configuration files, init scripts and support scripts.
2. Using apt-cache
You may also use apt-cache command to easily find out the dependencies of a package. Here is its syntax.
apt-cache depends [package_name]
Here is an example to get dependency information about apache server.
$ sudo apt-cache depends apache2
Here is the output, with dependencies mentioned one below the other.
apache2 PreDepends: dpkg Depends: lsb-base Depends: procps Depends: perl Depends: mime-support Depends: apache2-bin Depends: apache2-utils Depends: apache2-data Depends: <perl:any> perl Conflicts: <apache2.2-bin> Conflicts: <apache2.2-common> Recommends: ssl-cert Suggests: <www-browser> dillo edbrowse hv3 lynx chromium-browser elinks epiphany-browser falkon firefox konqueror links links2 netrik sugar-browse-activity surf w3m wslu xemacs21-mule xemacs21-mule-canna-wnn xemacs21-nomule Suggests: apache2-doc |Suggests: apache2-suexec-pristine Suggests: apache2-suexec-custom Suggests: ufw Replaces: <apache2.2-bin> Replaces: <apache2.2-common>
3. Check dependencies of .deb package
If you are using Ubuntu/Debian system, you can even use dpkg function to list details about a package. Here is its syntax.
dpkg --info [deb_file_path]
Here is an example to get package dependencies after you have downloaded the package.
dpkg --info Downloads/teamviewer_15.16.8_amd64.deb
In this article, we have learnt how to check dependencies of Linux packages. These options are available by default in almost every Linux distribution and do not require any installation. Apart from them, there are many third party tools like apt-rdepends you can use to get this information. However, you will need to install them to be able to use it.
It is important to note that apt-cache depends and apt show commands will list dependencies of package even if you have not downloaded them but dpkg -i command will work on only those packages that you have downloaded.
How to Iterate Over Multiple Lists in Python
How to Disable GZIP Compression in Apache
How to Install Specific NPM Package Version
How to Disable TLS 1.0 in Apache
How to Force User to Change Password in Linux