Ubuntu

How to Check Dependencies of a Package in Ubuntu 20.04

In the Ubuntu system, installing the packages using the command-line is popular among beginners as it seems quite easy. There are various ways to get the dependencies of a package in Ubuntu 20.04. But we need to know about the “package dependencies” for the folks who are unaware of it.

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:

apt show [package_name]

Let’s check what result you get for the “Mozilla firefox” package when running:

apt show mozilla firefox

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:

apt-cache depends [package_name]

Let’s take an example for better understanding. Check the dependency information of the “mozilla firefox” package:

apt-cache depends mozilla firefox

Take a look at another example!

To get the dependencies details of PHP:

apt-cache depends 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:

dpkg --info [deb_file_path]

Suppose I have the “.deb” package of Teamviewer in my Ubuntu machine. To get its dependencies detail, execute the mentioned command:

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

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:

$ sudo apt install apt-rdepends

The syntax of the apt-rdepends is straight forward:

apt-rdepends [options] [package_name]

Suppose you need to figure out the PHP dependencies. For that, execute the given command to get the desired output:

apt-rdepends php

Similarly, if we take another example:

apt-rdepends vlc

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:

apt-rdepends -r vlc

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.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.