ldd Command

The ldd command displays the shared library dependencies of an executable or shared library. It shows which dynamic libraries are required by a program and where they are located in the filesystem.

Syntax

ldd [OPTION]... FILE...

Description

The ldd command is essential for debugging library-related issues and understanding program dependencies. It shows which dynamic libraries are required and their memory addresses.

Common uses include:

  • Display shared library dependencies
  • Identify missing or broken library links
  • Debug dynamic linking issues
  • Analyze program dependencies for deployment
Security Warning: Never run ldd on untrusted executables as it may execute code from the target program during analysis.

Common Options

Option Description
-v Verbose mode - show version information
-d Perform data relocations and report missing objects
-r Perform data and function relocations
-u Show unused direct dependencies
--help Display help information
--version Display version information

Examples

Display dependencies of an executable

ldd /bin/ls

Shows all shared libraries required by the ls command

Check dependencies of a custom program

ldd ./myprogram

Displays dependencies for a custom executable

Verbose output with version information

ldd -v /bin/echo

Shows detailed version information for each library

Check for missing libraries

ldd ./broken_program

Look for "not found" messages indicating missing libraries

Analyze shared library dependencies

ldd /usr/lib/x86_64-linux-gnu/libssl.so.1.1

Shows what libraries a shared library itself depends on

Check unused dependencies

ldd -u ./myprogram

Identifies libraries that are linked but not actually used

Understanding Output

The ldd output format shows:

  • Library name - The name of the shared library
  • Arrow (=>) - Points to the actual library location
  • Library path - Full path to the library file
  • Memory address - Virtual memory address where library is loaded

Special cases:

  • not found - Library is missing or not in library path
  • linux-vdso.so.1 - Virtual dynamic shared object (kernel interface)
  • /lib64/ld-linux-x86-64.so.2 - Dynamic linker/loader
  • statically linked - Executable has no dynamic dependencies

See also