How to show all shared libraries used by executables in Linux?

LinuxOperating SystemOpen Source

We know that a shared library is a library that can be linked to any program at runtime. In order to view all the shared libraries used by an executable we make use of the Linux command utility known as ldd. We can easily locate the shared libraries on a Linux machine, as they usually start with lib* prefix.

Let’s first understand and see examples of how to make use of the ldd command that Linux provides us with.

Ldd is a command utility that Linux provides us with and is mostly used in case we want to know the shared library dependencies of an executable or even that of a shared library.

LDD Syntax

ldd [OPTION] .. FILE ..

The [OPTION] placeholder in the above command can be replaced by the flags that the ldd command provides us with, some of the most common ones are −

  • -v − Print all information

  • -d − Processes data relocation

  • -u − Used to print unused direct dependencies

  • -r − Processes data and function relocation

Now that we know a little bit about the ldd command, let’s explore a few examples of it where we will display dependencies of an executable and much more.

Example 1


ldd /bin/cp

In the above command we are running the ldd command on the executable named cp stored inside the /bin folder on your linux directory.

Output => (0x00007fffaf3ff000) => /lib64/ (0x0000003a06a00000) => /lib64/ (0x0000003a06200000) => /lib64/ (0x0000003a13000000) => /lib64/ (0x0000003a0ea00000) => /lib64/ (0x0000003a05200000) => /lib64/ (0x0000003a05a00000)
/lib64/ (0x0000003a04a00000) => /lib64/ (0x0000003a05600000)

We can also display the unused direct dependencies of an executable with the help of the command shown in the example below

Example 2


ldd -u /bin/cp


Unused direct dependencies:

Updated on 31-Jul-2021 11:55:39