Linux Libraries System

ldconfigshared library cache manager

ldconfig updates the system’s shared library cache used by the dynamic linker. It scans directories listed in /etc/ld.so.conf and builds /etc/ld.so.cache.

What ldconfig is good for

How it works

Linux executables link dynamically to shared libraries. Instead of searching every directory each time a program runs, the dynamic linker uses /etc/ld.so.cache.

ldconfig rebuilds that cache.

10 Practical Examples

1) Rebuild the library cache

sudo ldconfig

Run after installing a new shared library manually.

2) Show libraries currently in cache

ldconfig -p

Displays all libraries known to the linker.

3) Verbose mode

sudo ldconfig -v

Shows directories scanned and links created.

4) Update a specific directory

sudo ldconfig /usr/local/lib

Useful after installing custom-built libraries.

5) Search for a specific library

ldconfig -p | grep ssl

Confirm whether a library is registered.

6) Ignore auxiliary cache

sudo ldconfig -X

Skips updating symbolic links.

7) Update links only

sudo ldconfig -N

Does not rebuild the cache file.

8) Specify alternate root (chroot usage)

sudo ldconfig -r /mnt/sysroot

Used when preparing chroot or container environments.

9) Verify symbolic links

ls -l /usr/lib/libexample.so*

Ensure correct .so symlink chain exists.

10) Diagnose missing library error

sudo ldconfig
ldd /path/to/program

Rebuild cache, then inspect binary dependencies.

Notes & Gotchas