Shared libraries are used to provide functions to the commands and executable of the Linux.
ldd command can be used to list currently used shared libraries of given executable file.
ldd command is a simple command which provide some parameters this can be listed with the
--help option like below.
$ ldd --help
Print Given Executable Shared Libraries
We will start with the basic usage where we will print given executable file shared libraries. In this example we will use
$ ldd /bin/echo
We can see that libraries like
ld-linux-x86-64.so are used by the
echo binary. There is also the full path of the given libraries where they are generally resides in
Print All Information
We can print more detailed information about the given executable. We will use
-v option where we will print all information like versin and alternative libraries about given executable.
$ ldd -v /bin/echo
Print Data Relocations
We can also print the data relocations about the given libraries with the
$ ldd -d /bin/echo
Relocations are the memory addresses of the given part of the library.
Print Function Relocations
We can also print the function relocations of the given executable file with the
$ ldd -r /bin/echo