ldconfig — Linux Command — Unix Command

Use 'ldconfig' to set up appropriate links and caches for system libraries

The ldconfig Linux command creates the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib). It checks the header and file names of the libraries it encounters when determining which versions should have their links updated; it ignores symbolic links when scanning for libraries.

Ldconfig will attempt to deduce the type of ELF libs (ie. libc 5.x or libc 6.x (glibc)) based on what C libraries if any the library was linked against, therefore when making dynamic libraries, it is wise to explicitly link against libc (use -lc). 

Ldconfig should normally be run by the super-user as it may require write permission on some root owned directories and files. If you use -r option to change the root directory, you don't have to be super-user as long as you have sufficient rights to that directory tree.

Person working on a laptop computer.
Jag Images / Getty Images

Synopsis

The command takes the following general format:

ldconfig [OPTION...]

Options

The command supports the following options:

  • -v: Verbose mode. Print current version number, the name of each directory as it is scanned and any links that are created.
  • -n: Only process directories specified on the command line. Don't process the trusted directories (/usr/lib and /lib) nor those specified in /etc/ld.so.conf. Implies -N.
  • -N: Don't rebuild the cache. Unless -X is also specified, links are still updated.
  • -X: Don't update links. Unless -N is also specified, the cache is still rebuilt.
  • -f conf: Use conf instead of /etc/ld.so.conf.
  • -C cache: Use cache instead of /etc/ld.so.cache.
  • -r root: Change to and use root as the root directory.
  • -l: Library mode. Manually link individual libraries. Intended for use by experts only.
  • -p: Use print-cache to print the lists of directories and candidate libraries stored in the current cache.
  • -c: format=FORMAT: Specify the format for the cache file. Choices are old, new and compat (the default).
  • -?, help/usage: Display usage information.
  • -V version: Shows the program version.

Examples

Use ldconfig to set links. For example,

#

establishes the correct links for the shared binaries and rebuilds the cache, while running

# /sbin

as root after the installation of a new shared library will properly update the shared library symbolic links in /lib.