While installing software packages in the Linux operating system, some packages depend on other packages to function correctly. Sometimes they are already installed on the system, but, in other cases, they installed with the package automatically. These dependent packages are termed package dependencies.
There are multiple approaches to get dependencies details, such as using apt package manager, dpkg command, or installing a tool.
Let’s begin with the APT package management system to get the dependencies of a package.
How to Check Package Dependency with APT Show:
Execute the “apt show” command with the package name to get the complete details of a package.
Syntax of using this approach is:
Let’s check what result you get for the “Mozilla firefox” package when running:
As shown in the above image, the “firefox” package depends upon various libraries. The APT package manager plays a key role in the Linux system as it installs most of the dependencies automatically.
How to Check Dependencies Information with APT-Cache:
If you need the limited script of dependencies information, go with the “apt-cache” command.
Use the given syntax:
Let’s take an example for better understanding. Check the dependency information of the “mozilla firefox” package:
Take a look at another example!
To get the dependencies details of PHP:
How to check dependencies of a “.deb” package file:
If you have .deb file to install the software package, then the “apt” command won’t work.
For this, you can run the “dpkg” command with the “-I” or “–info” option to get details. So, the syntax would be:
Suppose I have the “.deb” package of Teamviewer in my Ubuntu machine. To get its dependencies detail, execute the mentioned command:
The above section was how to get package dependencies detail via apt and dpkg command.
But if you prefer a tool, then follow the approach given below:
How to check dependencies with the “apt-rdepends” tool:
There are numerous tools to check package dependencies, and you might get confused about which tool is the right tool to install. Also, you cannot be taking a risk to install any dependency that affects the running system.
The apt-rdepends is an authentic tool that helps to list down all the dependencies a software package has. It is not a built-in tool; to get it, use the command mentioned below:
The syntax of the apt-rdepends is straight forward:
Suppose you need to figure out the PHP dependencies. For that, execute the given command to get the desired output:
Similarly, if we take another example:
To reverse this, see what other packages depend on a specific software package, use the “-r” option.
For example, to check packages list depend upon the vlc package, the command is:
Conclusion:
The write-up has shown us how to check the package dependencies of a package on Ubuntu 20.04.
We have found various ways to get package dependencies using the command line. The APT package management system plays an important role as it installs most of the dependencies automatically. But if any software has downloaded via the .deb package, then the “dpkg” command is suggested.
The “apt-rdepends” tool is an alternative method to check dependencies. Using this tool, you can get the list of detailed package dependencies and find the reverse of it.