Library Paths

General Information

Configuring and viewing OS library paths.


  • Distro(s): Enterprise Linux 6/7

Library Config Files

Main Config File: /etc/ includes a directory


Directory of drop in paths: /etc/
Example: /etc/


Apply Changes: If any changes are made to the above config files, run ldconfig to reload the library cache

ldconfig -v
  • -v ⇒ verbose

Print the Cache Contents: To see what is currently in the library cache

ldconfig --print-cache

Library Search Order

Shared libraries needed by programs are searched for in this order:

  • Environment variable “LD_LIBRARY_PATH” ⇒ This environmental variable can be set like any other environment variable. (shell, .bashrc, .profile)
  • (ELF binaries only) ⇒ Directories specified within the binary. (DT_RUNPATH)
  • From cache file (/etc/ ⇒ created via ldconfig
  • In default system library paths (/lib, /lib64, /usr/lib)

Override Search Order

To get a path specified in front of another, define the environmental variable “LD_LIBRARY_PATH” in a configuration file (per user or system wide).

Example: Ensure that /usr/lib64 is ahead of /usr/local/lib for user “robert”

vim /home/robert/.bashrc
  • Including the “${LD_LIBRARY_PATH}” as a second entry ensures that nothing is completely over written if the variable has been set elsewhere

  • linux_wiki/library_paths.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)