Dependencies in Linux

A Complete Guide for Beginners Enroll Course Now

Installing useful software is one of the most essential tasks in our daily computing life. For example, you may be assigned to prepare a document or want to watch a movie. So, you need to install a document writer or a media player. In Linux, every software is in the form of packages. But, installing a software package may depend on some other packages as a prerequisite. These packages are called dependencies. Dependencies must have to be installed before to ensure the successful installation of the original package.

Key Takeaways

  • Getting a comprehensive idea about dependencies.
  • Learning the commands to check package dependencies in different Linux distributions.
  • Handling automatic dependency resolution when installing and uninstalling a package.
  • Knowing about some common errors regarding dependencies and their solutions.


  • System running on Ubuntu/RedHat/ArchLinux.
  • Login credentials to the system to enable sudo privilege.

What are Linux Dependencies?

Regarding Linux, dependencies are some software packages that are prerequisites to run another package or program smoothly. Most of the software packages you use daily in Linux reuse functions from other packages. So, to ensure a successful and complete installation of your intended package, you need to install those additional packages. These packages are known as dependency packages. Technically, dependencies can be of many types that I will discuss now.

Types of Dependencies in Linux

1. Runtime Dependency: These are libraries, binaries, or other software components that a program relies on to run successfully after it’s been installed on a user’s system. This category can further be divided into the following:

  • Shared Libraries: Shared Libraries provide common functionalities that multiple programs can use.
  • System Services: Background services and daemons that provide specific functionality required for applications to work correctly.

2. Package Dependency: Packages themselves can have dependencies on other packages. This is common in package management systems like APT, where installing one package might trigger the installation of other packages it depends on.

3. Build Dependency: These are packages and tools required to build and compile software from its source code. Developers who compile software from source code need to manage these dependencies.

  • Development Dependencies: These are packages and tools that provide development-related functionalities, such as compilers, headers, development libraries, and debugging tools.
  • Optional Dependencies: Sometimes a software package can have optional dependencies that extend functionality but are not strictly required.

Types of dependencies hierarchy.Basically, daily users of Linux systems face package dependency issues. In this tutorial, you’ll get a clear idea about package dependencies and their handling.

How to Check Package Dependencies?

Dependencies are the most crucial part to handle when installing a software package. That’s why, you may need to check the dependencies before installing a package. Every distribution in Linux has commands that you can use to check the dependencies of a package. Some of them are listed below:

Distribution Command to Check Dependencies
Ubuntu apt show <package-name>
RHEL yum deplist <package-name>
Fedora sudo dnf info <package-name>
ArchLinux pactree -r <package-name>
OpenSUSE sudo zypper info <package-name>
Note: Replace <package-name> in the above commands by the actual name of the package.

Dependencies in Ubuntu

Package managers are used to handle installing, removing, and updating a package. And dependencies are mostly connected with those tasks. However, Ubuntu has two widely used package management tools called apt and dpkg. Let’s discuss their usage in dependency resolution.

Install Dependencies Automatically in Ubuntu

If you’re using Ubuntu and want to automatically handle dependencies when installing packages, apt is designed to handle dependencies automatically by default. That means, when you use apt to install a package, it will take care of downloading and installing the package as well as any dependencies required. You generally don’t need to worry about managing dependencies manually. The command for installing a package with its dependency by apt is:

sudo apt install <package-name>
Note: Replace <package-name> with the actual name of the package you want to install.

DPKG to Install Dependencies

dpkg is a lower-level package management tool in Debian-based systems i.e. Ubuntu that directly installs, removes, or manages individual Debian package (.deb) files. dpkg does not automatically resolve dependencies. You would need to manage dependencies manually if you use dpkg directly. Command for installing a .deb file using dpkg is:

sudo dpkg -i <filename.deb>

When you try to install a .deb file, it will show the dependency list in the terminal. Then you have to manually download the dependency packages from a trusted source and install them with the above command before installing the intended package.

Dependencies in RedHat

yum and rpm are two package management tools available for RedHat-based Linux distributions. Here, yum is a high-level package management tool that can automatically handle dependencies while installing or updating a package but rpm can’t.

YUM to Install Package With Dependencies

Yum is by default degined to streamline the process by automatically managing dependencies for you. To install a package and its dependencies using yum, simply use the following command with the actual package name in the place of <package-name>:

sudo yum install <package-name>

Using RPM to Install Package

RPM is a low-level package manager in RedHat-based systems such as RHEL, Fedora, CentOS, etc. It doesn’t install dependencies automatically. The command for installing a package using rpm is:

sudo rpm -ivh <package.rpm>

Install RPM Package Without Dependencies

If the package you want to install using rpm has dependencies then the above command can’t install the package and shows the dependency list that is to resolve first. However, installing RPM packages without dependencies can lead to potential issues and an unstable system. Still, if you are sure that you want to install the package ignoring the dependencis, use this command for that purpose:

sudo rpm -ivh –nodeps <package.rpm>
Note: Replace <package.rpm> with the filename of the RPM package you want to install.

Dependency Tree

The dependency tree refers to the hierarchical structure of dependencies that exist between software packages on a Linux distribution. In a dependency tree, packages are organized in a way that shows which packages depend on others to function properly. Here, dependencies can be either runtime dependencies, which are required for the software to run, or build dependencies, which are required to compile or build the software. For example, the dependency tree of VLC player looks like this:Dependency tree of VLC player.

APT Dependency Tree

The APT dependency tree is the hierarchical structure of dependencies that is previewed by APT. If you are using Ubuntu or any other Debian-based Linux distribution, you can use apt package manager tool to list hierarchical dependency structure of a package by the following command:

sudo apt-get install -y apt-rdpends

sudo apt-rdepends <package-name>

Reverse Dependencies

Reverse dependency means the backward dependencies of a package. Actually, it is opposite to forward dependencies. For example, if Package B is required by Package A, then Package A becomes a reverse dependency of Package B.Dependency and Reverse Dependency among Package A, B, C visualized.You can use commands from the table below to see reverse dependencies of a package.

To View Command
APT Reverse Dependency sudo apt-rdepends -r <package-name>
RPM Reverse Dependency rpm -q –whatrequires <package-name>
Pacman Reverse Dependency pactree -r <package-name>
Note: RPM Reverse Dependency can be used only for installed packages. Replace <package-name> in the all above commands by the actual name of the package.

Remove Package and Dependencies

Removal of a package is as necessary as installing it. Because unnecessary packages cost system memory. However, you may not be using an installed package because you don’t need it anymore. Besides, sometimes you may need to install a package for doing a one-time task. Linux provides the option to remove a package with or without its dependencies. You can use commands from the table below according to your need:

Distribution Remove Only the Package Remove Package With Dependencies
Ubuntu sudo apt remove <package-name> sudo apt autoremove <package-name>
RHEL, CentOS, Fedora sudo yum remove <package-name> sudo yum erase <package-name>
ArchLinux sudo pacman -R <package-name> sudo pacman -Rs <package-name
Note: Replace <package-name> in the all above commands by the actual name of the package.

Common Challenges That May Arise

Though some package managers automatically handle dependencies, the following errors occur most frequently when installing and updating a package:

A. Packages Have Unmet Dependencies

A common problem in installing a package is dependency unmet. Usually, some package managers such as APT (Advanced Package Tool) install dependencies before installing the intended package. But when you use lower-level package managers like DPKG to manually handle dependencies, an error message may appear like “the following packages have unmet dependencies”. This typically happens when a package you’re trying to install or update requires other packages to be present, but those required packages are either missing or not compatible with the current system configuration.

B. RPM Error Failed Dependencies

This is a dependency problem that is generally found in RedHat-based Linux distributions where RPM is the package manager. While installing or removing a .rpm file manually, you may get failed dependencies error. It happens because there may require a certain pre-requisite rpm to be installed before installing the main rpm. So, to solve this problem, you must install those pre-requisite packages before.


Modern package managers in Linux distributions, such as apt in Debian-based systems, yum in RedHat-based systems and pacman in ArchLinux, automatically handle dependencies when you install or update software packages. This automation simplifies the process of managing software and contributes to a smoother and more reliable computing experience. Moreover, you can manually resolve dependencies by low-level pacakge management tools such as dpkg in Debian and rpm in RedHat.

People Also Ask

How to find dependencies in Linux?
You can use the apt-rdepends tool to create the complete dependency tree. By running sudo apt-rdepends <package-name> command, you get the dependency of a package and the dependencies of the dependencies as well in Ubuntu. Use rpm -qR <package-name> for RHEL, Fedora, and CentOS.
How do Linux dependencies work?
Linux dependencies are simply some pre-requisite packages that a program needs to run. Developers write Linux software in a modular way to increase reusability. So, dependencies work as a shared library that is used by other packages to run with full functionality.
How to add dependencies in Linux?
Dependencies are usually listed in the metadata file of a package. When you try to install or update a package, your systems package manager check the metadata file to list which additional packages are to install. To add dependencies automatically while installing a package, you should install the package with yum or apt
How do I list all dependencies?
If you are using a Debian-based system such as Ubuntu, sudo apt-rdepends <package-name> will list all the dependencies in a recursive manner. For RedHat-based system i.e. RHEL, Fedora, and CentOS, run rpm -qR <package-name>
Where are dependencies located?
Shared libraries dependencies are typically located in directories like /lib or /usr/lib. Executable file dependencies are usually located in directories like /bin, /usr/bin, /sbin, and /usr/sbin.

Related Articles

<< Go Back to Package Management in Linux | Learn Linux Basics

Rate this post
Ashikur Rahman

Hello, I’m Ashikur Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation in Computer Science and Engineering from Khulna University of Engineering & Technology (KUET). Also, I’m pursuing my master’s in the same department at Bangladesh University of Engineering & Technology (BUET). I like to learn new technologies, contribute, and share those with others. Here my goal is to provide beneficial and user-friendly articles on Linux distribution for everyone. Read Full Bio

Leave a Comment