The ldd utility lists dynamic dependencies, basically the shared libraries needed to make a binary file work. It is the first thing to check when a program refuses to start with an error such as error while loading shared libraries: libfoo.so.1: cannot open shared object file. Here’s the basic syntax:
ldd /path/to/binary
Prerequisites
- ldd is part of glibc (the
glibc-commonorglibcpackage on CentOS/RHEL), so it is already installed. - Root is not required to read most binaries; this example logs in and uses root.
1. Change to a bin directory
Log in, and su to root.

Change to /sbin, or some other bin directory:
cd /sbin

2. Run ldd on the binary
If you do an ldd {binary name} it will return what its dependencies are:
ldd mkfs

That’s it!
Reading the output
Each line is one library the binary is linked against:
libc.so.6 => /lib64/libc.so.6 (0x...): the library name the binary asks for, the file the dynamic linker found for it, and the address it was loaded at.linux-vdso.so.1: a virtual library the kernel provides in memory, so it has no file path./lib64/ld-linux-x86-64.so.2: the dynamic linker itself.libsomething.so.1 => not found: the library the program is missing. This is the line you are looking for when a program will not start.
For a statically linked binary or a shell script, ldd prints not a dynamic executable.
Fixing a “not found” library
Find the package that ships the missing file, then install it:
yum provides '*/libsomething.so.1'
yum install packagename
If the library is already on disk somewhere the linker does not search, such as /usr/local/lib or /opt/app/lib, add that directory to a file in /etc/ld.so.conf.d/ and rebuild the linker cache:
echo /opt/app/lib > /etc/ld.so.conf.d/app.conf
ldconfig
ldconfig -p | grep libsomething
For a quick one-off test you can instead set LD_LIBRARY_PATH=/opt/app/lib before the command.
Untrusted binaries: use objdump instead
The ldd man page warns that ldd may run the program in some cases, so never point it at a binary you do not trust. To list the libraries a file asks for without running anything, read the ELF header:
objdump -p ./binary | grep NEEDED
readelf -d ./binary | grep NEEDED
These list what the binary asks for but do not resolve the paths.
RHEL, AlmaLinux and Rocky Linux 9 and 10
ldd works exactly the same. Since RHEL 7, /sbin is a symlink to /usr/sbin (and /lib64 to /usr/lib64), so you may see /usr/lib64 paths in the output. Use dnf provides '*/libsomething.so.1' to find the package for a missing library.
Hosted Linux Servers at www.zwiegnet.com/go
Related guides: Downgrade package CentOS 6 · Developing Applications for RHEL/CentOS · Show Line Numbers with Vi
