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.
Help
Even 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 echo
executable.
$ ldd /bin/echo

We can see that libraries like linux-vdso
,libc.so
and 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 /lib
or /lib64
directories.
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 -d
option.
$ 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 -r
option.
$ ldd -r /bin/echo
