Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
![](https://www.devsecopsnow.com/wp-content/uploads/2025/01/image-151.png)
The ldd
(List Dynamic Dependencies) command in Linux is used to display shared library dependencies of an executable or a shared object (.so
file). It helps in debugging missing dependencies, checking linked libraries, and troubleshooting runtime issues.
1. Check Shared Libraries for an Executable
ldd /bin/ls
โ What it does:
- Lists all shared libraries (
.so
files) required by/bin/ls
.
๐ Example Output:
linux-vdso.so.1 (0x00007ffd7d9f0000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f3e6d8d0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3e6d6c0000)
๐ก Useful for checking dependencies before running an application.
2. Check Shared Libraries for a Shared Object (.so
file)
ldd /lib/x86_64-linux-gnu/libc.so.6
โ What it does:
- Displays dependencies of the
libc.so.6
shared library.
๐ Example Output:
/lib/x86_64-linux-gnu/libc.so.6:
linux-vdso.so.1 (0x00007ffd7d9f0000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3e6d6c0000)
๐ก Helps in debugging shared object dependencies.
3. Find Missing Dependencies
ldd /usr/bin/program | grep "not found"
โ What it does:
- Identifies missing libraries for an executable.
๐ Example Output:
libssl.so.1.1 => not found
libcrypto.so.1.1 => not found
๐ก Useful for troubleshooting missing library errors.
4. Check Dependencies for a Custom Binary
ldd /home/user/my_program
โ What it does:
- Displays shared libraries required by custom binaries.
๐ Use case:
- Before deploying an application, check which libraries are required on another system.
5. Display Only Paths of Shared Libraries
ldd /bin/bash | awk '{print $3}'
โ What it does:
- Extracts only the paths of the shared libraries.
๐ Example Output:
/lib/x86_64-linux-gnu/libtinfo.so.6
/lib/x86_64-linux-gnu/libc.so.6
/lib64/ld-linux-x86-64.so.2
๐ก Useful for listing all linked libraries in a script.
6. List Dependencies for a Python Interpreter
ldd $(which python3)
โ What it does:
- Shows all libraries required by Python.
๐ Example Output:
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2
๐ก Helps when debugging Python runtime issues.
7. Find Dependencies for a Java Virtual Machine (JVM)
ldd $(which java)
โ What it does:
- Displays required libraries for the Java runtime environment.
๐ Use case:
- Identify if a missing library is causing Java to fail.
8. Find Which Library Provides a Missing Dependency
ldd /usr/bin/ffmpeg | grep "not found"
ldconfig -p | grep libavcodec
โ What it does:
- The first command finds missing dependencies.
- The second command searches for the missing library.
๐ Example Output (if missing library found):
libavcodec.so.58 (libavcodec.so.58 -> /usr/lib/x86_64-linux-gnu/libavcodec.so.58)
๐ก Useful for resolving broken dependencies in multimedia software.
9. Check Dependencies of a Statically Linked Binary
ldd /bin/busybox
๐ Example Output (if statically linked):
not a dynamic executable
โ What it means:
- BusyBox is statically linked, meaning all libraries are compiled inside the binary.
๐ก Useful when working with lightweight embedded Linux systems.
10. Debug ELF Binaries with LD_TRACE_LOADED_OBJECTS
LD_TRACE_LOADED_OBJECTS=1 /usr/bin/bash
โ What it does:
- Alternative to
ldd
, directly traces loaded libraries.
๐ Example Output:
linux-vdso.so.1 => (0x00007ffd7d9f0000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3e6d6c0000)
๐ก Useful when ldd
is not available or for debugging manually.
Final Thoughts
ldd
is essential for debugging shared library dependencies.- Always check missing dependencies (
grep "not found"
). - Use
ldconfig -p
to find missing libraries.