Linux offers ample flexibility as it allows you to tune your system according to your needs. That means you can easily operate your system via the Terminal. Moreover, you can control various parameters and keep a check on the files shared and used by different programs on your system.  One command, in particular, enables you to recognize the libraries used by a given program under inspection. This is the LDD command developed by Roland McGrath and Ulrich Drepper. LDD (List Dynamic Dependencies) facilitates the user to identify the library dependencies that are being shared across various executable files. This guide will help you learn how to use the LDD command in Linux. So without further ado, let’s begin!

Types of Libraries.

A library is a well-defined set of functions, objects, variables, classes, type specifications, conditions, and subroutines that dictate the operations of files and programs, without having to maintain the source code. There are three types of libraries: This reduces the memory consumption, thereby minimizing program size and improving performance. They usually have “.so”  extensions. Most executable files we use on a day-to-day basis contain shared libraries. LDD command lists the dynamic library dependencies. These libraries are reused and shared across programs to ease the development of programs and reduce their size and load on the computer’s memory. In Linux, these files are in the form of a “.so” extension, and they are stockpiled in /usr/lib* or simply /lib*. Various distributions of Linux systems may package a different set of libraries for a program, making it work differently on different versions of the operating system. When a shared library for a program is not available on your system, you get an error that may look like this: We can then check the shared libraries for a particular program using the LDD command.

Installing the LDD Command.

The LDD command is inherently available in nearly every Linux distribution. In case it is not, you can use the following command to install it: The $ ldd command has the following syntax: Or more generally: LDD is a basic, yet powerful command. It offers help and other variations using different flags. They are briefly described below. –version: To display the ldd version currently in use. -v –verbose: To display info intricately. -u –unused: To display unused dependencies. -d –data-relocs: To relocate and identify missing objects. -r –function-relocs: To relocate data objects and functions and identify missing functions or objects. –-help: To provide help regarding command usage.

Using the LDD Command.

Now that you have completed the installation, you are ready to learn how to use the LDD command in Linux. We will demonstrate this along with how it helps identify shared libraries. We will look into the shared libraries for Bash, the standard shell on Linux. It is responsible for executing commands and providing an interface between user and OS. To use the LDD command, follow these steps: As you can see, the shared library dependencies are visible. For a detailed and more intricate overview, use the -v flag with the $ ldd command as follows: Similarly, we can use the -u flag to display the unused dependencies. In the case shown above, there are no unused dependencies. It is always advised to keep tabs on which libraries are idle and consuming memory.  Failing to do so may load up your kernel with unused files, consequently hindering performance. It would be helpful to check out our article on how to free space on Ubuntu. For the data and function relocations, we use the -d and -r  flags respectively alongside the $ ldd command. These flags also help identify missing objects and functions. Last, but not least, we can use the –help flag for a quick consult regarding the flags and their respective actions.

Limitations of the LDD Command.

It should be noted that the LDD command won’t work on programs that are not dynamically executable, “a.out” shared libraries or files that are outdated or were developed before the LDD came out. Finally, it is advised that LDD commands should not be used with untrusted sources as it can result in abrupt errors and exceptions. The manual page for LDD suggests an alternative command which is composed of objdump and grep utilities. LDD is one of those undermined instructions that, if used the right way, can make a substantial difference in your interaction with the OS. It is a powerful linking command with a specific purpose, and it definitely delivers. For more details on the command and its usage, you can head to the man page for the LDD command. We hope this guide helped you learn how to use the LDD command in Linux. If you are having any troubles understanding something, or if you have suggestions on how to make our guides better, let us know in the comment section down below.

How to Use LDD Command in Linux - 4How to Use LDD Command in Linux - 17How to Use LDD Command in Linux - 9How to Use LDD Command in Linux - 15How to Use LDD Command in Linux - 47