LPIC 102.3 Manage shared libraries

Weight: 1

Description: Candidates should be able to determine the shared libraries that executable programs depend on and install them when necessary.

Key Knowledge Areas:

  • Identify shared libraries
  • Identify the typical locations of system libraries
  • Load shared libraries

Terms and Utilities:

  • ldd
  • ldconfig
  • /etc/ld.so.conf
  • LD_LIBRARY_PATH

Software in a Linux System

A typical piece of software is comprised of 5 pieces:

  • Binary
  • Library
  • Configuration
  • Documentation
  • Data

These 5 pieces may located in different folders to follow FHS1 (Filesystem Hierarchy Standard).

Shared Library
Libraries are reusable components that a software developer can link to an application so that the library’s functionality can be used.

  Much of what a software developer needs to do has already been done. Writing files to disk, displaying windows, even talking over the network—Linux has libraries that handle all of these.
  Even the software itself will provide libraries for other developer to use. Such as a database providing library for other applications to query it.

Linux uses the GNU C library (glibc) version of the C library.

There are 2 kinds of libraries
Static link library - a library copy is compiled into the resulting application
Dynamic link library - application compiled with library name but not the entire library codes. Application will search required library system-wide when need use library's function.

Dynamic linking is used in almost all cases because it saves disk space and eases upgrades.  

dynamic linker
An application that needs to use a shared library asks a service called ld.so, also known as the dynamic linker2.
The dynamic linker knows where all the shared libraries are stored and loads the library for the application.

Config Library Path
library path is set in the /etc/ld.so.conf file and /etc/ld.so.conf.d/xxx.conf

There’s seldom a need to change the library path systemwide.  

After you change your library path, you must use ldconfig to have your programs use the new path.

Both RPM and Debian library packages typically run ldconfig automatically after installing or removing the package.

The same thing happens as part of the installation process for many packages compiled from source.

ldd - print shared library dependencies
ldd /bin/ls

The LD_LIBRARY_PATH environment variable contains a colon separated list of paths that the linker uses to resolve library dependencies of ELF(Executable and Linkable Format) executable at run-time. These paths will be given priority over the standard library paths /lib and /usr/lib. The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH has been exhausted.


  1. The Filesystem Hierarchy Standard (FHS) defines the directory structure and directory contents in Unix-like operating systems.[1] It is maintained by the Linux Foundation.Read More

  2. Dynamic linker is the part of an operating system that loads and links the shared libraries needed by an executable when it is executed (at "run time"), by copying the content of libraries from persistent storage to RAM, and filling jump tables and relocating pointers.(https://en.wikipedia.org/wiki/Dynamic_linker)