Check a binary's shared libraries with `ldd`

The command behind 'error while loading shared libraries: libX.so.1: cannot open' — ldd lists every needed .so and whether it resolves.

Linuxlddlinkingdependenciesshared-librariesLow risk
Run `ldd /path/to/binary` to list its shared library dependencies; any line reading `not found` is the missing library to install or ship.

01Command

Command
$ ldd /usr/bin/some-binary

02What it does

Each output line maps a needed library (e.g. libssl.so.3) to its resolved path; 'not found' means the dynamic linker can't locate it, which you fix by installing the package or extending the search path with `LD_LIBRARY_PATH`. The man page's forgotten security note matters: ldd works by running the program's loader, so never use it on untrusted binaries — use `objdump -p binary | grep NEEDED` instead. Related and forgotten: `ldconfig -p` shows every library the system cache knows about.

03Risk

RiskLow risk
RequirementsPreinstalled with glibc on all Linux distros
!Warning: Never run ldd on untrusted executables — it can execute arbitrary code from the binary's loader.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Developer