Overview
ldd displays the list of dynamic libraries required at runtime by an ELF (Executable and Linkable Format) executable or shared library. It can be used for resolving missing library issues, verifying build environments, and security analysis.
Key Features
- Check dynamic library dependencies of a program
- Verify the system path for each library
- Identify missing libraries and assist in troubleshooting
Key Options
The ldd command allows you to control the level of detail in the output through various options.
Information Output Control
Generated command:
Try combining the commands.
Description:
`ldd` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Basic Usage: Check dependencies of /bin/ls
ldd /bin/ls
Prints the list of shared libraries required by the /bin/ls executable.
Check dependencies of /usr/bin/python3 with verbose output
ldd -v /usr/bin/python3
Prints the dependencies of the /usr/bin/python3 executable with detailed information.
Check dependencies of a specific shared library
ldd /lib/x86_64-linux-gnu/libc.so.6
Checks the dependencies of the libc.so.6 shared library itself.
Tips & Warnings
Points to note and useful tips when using ldd.
Security Warning
ldd works by directly executing the binary to check library dependencies. Therefore, using ldd on untrusted executables can be a security risk. For unknown binaries, it is safer to use tools like `readelf -d`.
Usage Tips
- **Debugging Missing Library Errors**: When a program fails with a 'shared library not found' error, ldd can quickly identify which library is missing.
- **Preparing Container Environments**: When creating container images (e.g., for Docker), ldd can help determine the minimal set of libraries required for execution, optimizing image size.
- **Verifying Cross-Compilation Environments**: Useful for checking if a binary compiled for a specific architecture is linked against the correct libraries.