How To Use Linux ldd Command To Print Shared Libraries with Examples? – POFTUT

How To Use Linux ldd Command To Print Shared Libraries with Examples?


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
ldd Help
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
Print Given Executable Shared Libraries
Print Given Executable Shared Libraries

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 All Information
Print All Information

Print Data Relocations

We can also print the data relocations about the given libraries with the -d option.

$ ldd -d /bin/echo
Print Data Relocations
Print Data Relocations

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
Print Function Relocations
Print Function Relocations

LEARN MORE  How To Download, Compile and Install Custom Linux Kernel Manually In Ubuntu, Debian, Mint, Kali, CentOS?

Leave a Comment