ldconfig(8)
Configure dynamic linker run-time bindings and maintain the dynamic linker cache.
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
| Flag | What it does |
|---|---|
-p | Print the contents of the current cache; shows all cached libraries and their paths |
-c FORMAT | Set cache format; use 'old' for old format or 'new' for new format (default: new) |
-C CONFIG | Use alternative configuration file instead of /etc/ld.so.conf |
-f CONFIG | Use alternative configuration file (same as -C) |
-n | Process only directories on command line; ignore ld.so.conf and default directories |
-l | Library mode; manually link a library (rarely used) |
-N | Don't rebuild cache; only update links |
-X | Don't update links; only rebuild cache |
-v | Verbose output; print all processing steps |
-r ROOT | Change 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 ldconfigList all cached libc libraries and show their paths
ldconfig -p | grep libcRebuild cache with verbose output showing each library found and processed
sudo ldconfig -vProcess only /usr/local/lib directory, ignoring standard directories and ld.so.conf
sudo ldconfig -n /usr/local/libCount the total number of cached libraries in the system
ldconfig -p | wc -lUse an alternative configuration file for rebuilding the cache
sudo ldconfig -C /etc/ld.so.conf.d/custom.confRebuild cache for a system mounted at /mnt/target (useful for rescue/chroot operations)
sudo ldconfig -r /mnt/target