How to Check Dependencies of a Package in Ubuntu 22.04

Ubuntu comes with many packages that are used for performing many tasks of daily life. For example, we have a VIM text editor to edit different text files, VLC media player to run different media files, and VNC to access other computers remotely. Many of these applications that are included in the default repository of Ubuntu depend on some other packages as well. In order to install and use them, the dependency packages must be installed.

In this blog, we are going to find out different methods to check dependency packages before installing any package.

How to check dependencies of a package on Ubuntu 22.04?

There are three different methods using which we can find out the dependencies of the package we want to install using the terminal:

  • Using the apt package manager
  • Using the dpkg manager
  • Using the third-party tool

Method 1: How to check dependencies of a package using the APT package manager on Ubuntu 22.04?

The default package manager of Ubuntu and other Debian-based Linux distributions is APT package manager. But wait, for the readers who are not familiar with the package manager; a package manager in Linux distributions is used to manage the packages of Linux operating systems; such as, installing, updating, and removing packages.

An APT package manager is the most popular package manager, which can manage the packages of Ubuntu. We can use two different commands to find out the dependencies of a package on Ubuntu, one of them is using the “show” option with the APT package manager, and the other is by using the “apt-cache depends”.

If you want to find out the dependencies of the package using the “show” option, then the general syntax of the command will be:

$ sudo apt show [package name]

Simply replace the “[package name]” with the package name to show the dependencies of that package.

For example, to know the dependencies of VIM editor before installing it, use the command:

$ sudo apt show vim

Another option to find out the dependencies using the APT package manager is with the apt-cache, whose general syntax is:

$ sudo apt-cache depends  [package name]

Again, simply replace the “[package name]” with the package whose dependency you want to know, for example, to find out the dependencies of VIM package:

$ sudo apt-cache depends vim

Method 2: How to check dependencies of a package using the dpkg package manager on Ubuntu 22.04?

Similar to the APT package manager, dpkg is another package manager used particularly to manage the Debian or commonly known as deb packages on Ubuntu. So if there is a downloaded deb package on the Ubuntu and you want to know the packages on which its installation is dependent, then the conventional method is to use the “–info” option with the dpkg command. The general syntax for finding the dependencies of any deb package is:

$ sudo dpkg --info [package name]

To understand the usage of the above general syntax of dpkg, we will find out the dependencies of the downloaded deb package of Teamviewer by replacing it with the “[package name]” in the above command:

$ dpkg --info ./teamviewer_amd64.deb

Method 3: How to check dependencies of a package using the third-party tool on Ubuntu 22.04?

Besides using the package managers, there are different third-party tools that can be installed from the default repository of Ubuntu and can be used to check the dependencies of a package. One of the popular tools is “apt-rdepends” which is used to find out the dependencies of any package on Ubuntu.

To install apt-rdepends simply use the command mentioned below:

$ sudo apt install apt-rdepends -y

Once the package is successfully installed, you can use it to find the dependencies of any package on Ubuntu by following the general syntax of using it:

$ sudo apt-rdepends [package name]

Following the above general syntax, we will replace the “[package name]” with “vim” to find out its dependencies:

$ sudo apt-rdepends vim

By following these three simple and easy to use methods, one can check dependencies of a package in Ubuntu 22.04 efficiently.

Conclusion

Dependencies of packages on Ubuntu means the packages on which the performance, launching, and operation of that particular package depends. It should make assure that all dependencies of any package are installed, and in this write-up, we discussed three different methods by which we can find out the dependencies of any package on Ubuntu 22.04.