$linuxjunkies
>

ldconfig(8)

Configure dynamic linker run-time bindings and maintain the dynamic linker cache.

UbuntuDebianFedoraArch

Synopsis

ldconfig [OPTION]... [DIR]...

Description

ldconfig creates, updates, and maintains the necessary links and cache used by the dynamic linker to find and load shared libraries (.so files) efficiently at runtime. It reads configuration files, scans directories for shared libraries, and generates the cache file /etc/ld.so.cache.

Without arguments, ldconfig scans the default directories (/lib, /usr/lib, etc.) and those listed in /etc/ld.so.conf. It must be run as root to update the system cache. This command is typically executed during system startup and after installing new libraries.

Common options

FlagWhat it does
-pPrint the contents of the current cache; shows all cached libraries and their paths
-c FORMATSet cache format; use 'old' for old format or 'new' for new format (default: new)
-C CONFIGUse alternative configuration file instead of /etc/ld.so.conf
-f CONFIGUse alternative configuration file (same as -C)
-nProcess only directories on command line; ignore ld.so.conf and default directories
-lLibrary mode; manually link a library (rarely used)
-NDon't rebuild cache; only update links
-XDon't update links; only rebuild cache
-vVerbose output; print all processing steps
-r ROOTChange to ROOT directory before processing (useful for chroot environments)

Examples

Update the dynamic linker cache using default directories and /etc/ld.so.conf configuration

sudo ldconfig

List all cached libc libraries and show their paths

ldconfig -p | grep libc

Rebuild cache with verbose output showing each library found and processed

sudo ldconfig -v

Process only /usr/local/lib directory, ignoring standard directories and ld.so.conf

sudo ldconfig -n /usr/local/lib

Count the total number of cached libraries in the system

ldconfig -p | wc -l

Use an alternative configuration file for rebuilding the cache

sudo ldconfig -C /etc/ld.so.conf.d/custom.conf

Rebuild cache for a system mounted at /mnt/target (useful for rescue/chroot operations)

sudo ldconfig -r /mnt/target

Related commands