Linux Libraries (Paths, Files, and Commands)

This topic was published by and viewed 2062 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author

  • DevynCJohnson
    • Topics - 437
    • @devyncjohnson

    Linux has a variety of library files in many locations. Learning the names, locations, and purposes of some of these libraries may help users and admins better understand their Linux system.

    Library File Extensions

    • *.a - These are statically linked libraries. Static libraries are linked into programs.
    • *.bin - These libraries are binary files.
    • *.fw - Firmware files are special libraries/drivers for hardware.
    • *.ko - Files for kernel modules typically use this extension.
    • *.o - Many loadable kernel modules/objects are object files.
    • *.so - These files are dynamically-linked shared libraries that are not linked put into programs. Rather, programs reference this library and obtain functions/code from it.


    • Glib - Low-level GTK library
    • glibc - GNU Standard C Library
    •,*,, ld*.so - These libraries find and load shared libraries needed by software. Next, they execute the software that requested the shared libraries. Most Linux applications that are compiled use dynamically linked libraries. "" and its related files manage a.out binaries while "" (and others) is used by ELF binaries. These libraries are typically found in /lib/.
    • libc - Standard C Library (
    • libcanberra - Implementation of the Freedesktop name and sound theme specifications
    • libcurses - Ncurses interface library
    • libgio - Library interface to virtual file systems
    • libhybris - Compatibility layer for executing binaries made for Bionic-based Linux systems (like Android)
    • libntfs - Access and manage NTFS filesystems
    • librsvg - SVG rendering library
    • libxaw7 - X Athena Widget Set library
    • libxml2 - XML parser library
    • libxslt - XSLT C library

    Library Paths

    • /lib/ - The important shared library files are kept in here. Mainly these are system libraries or low-level libraries. The Linux kernel modules are kept under /lib/modules/ and firmware drivers are under /lib/firmware/.
    • /lib*/ - Other library directories may exist under root. For instance, /lib64/ contains 64-bit specific libraries and /lib32/ contains 32-bit libraries.
    • /lib/firmware/ - Various low-level drivers and modules for hardware are stored in this folder.
    • /lib/firmware/*-generic/ - This directory is named after the version of the available Linux kernels. Contained in this directory are firmware libraries that are specific to the specified kernel version.
    • /lib/modules/ - The drivers/modules that are stored under here are the loadable kernel modules. When modprobe inserts a module into the running kernel, modprobe is inserting modules that are under this directory. The filesystem drivers are also under this directory. For instance, the FAT filesystem driver is /lib/modules/3.16.0-36-generic/kernel/fs/fat/msdos.o.
    Linux Filesystem Modules
    Linux Filesystem Modules
    • /libexec/ - These are shared executable libraries.
    • /usr/lib/ - Program libraries are stored here. These libraries are either multiarch or specific to the current system.
    • /usr/libexec/ - These are application-specific executable libraries.
    • /usr/lib32/ - 32-bit specific application libraries are found here.
    • /usr/libx32/ - 32-bit specific application libraries are found here.
    • /usr/lib64/ - 64-bit specific application libraries are found here.
    • /usr/local/lib*/ - Locally installed libraries are placed here.

    Library Path

    Just as the list of paths containing executables are listed in the $PATH variable, the libraries are also listed in a special variable. This variable is $LD_LIBRARY_PATH. If users wanted to add /opt/lib/ to the library path variable, then the user would execute export LD_LIBRARY_PATH=/opt/lib:$LD_LIBRARY_PATH.

    /etc/ is a directory that contains a list of configuration files that list the library paths for each architecture type.

    collier@Nacho-Linux:/etc/$ ls
    collier@Nacho-Linux:/etc/$ cat ./x86_64-linux-gnu.conf
    # Multiarch support

    Special Commands

    Users can see a list of libraries needed by an executable by running the "ldd" command. In a terminal/command-line, run ldd EXECUTABLE_PATH to see the libraries needed by the executable. For example, to list the libraries needed by Firefox, the below code would be seen.

    collier@Nacho-Linux:~$ ldd /usr/bin/firefox
    not a dynamic executable

    This indicates that Firefox uses static libraries that are built into the executable. However, the "cp" command uses dynamic libraries.

    collier@Nacho-Linux:~$ ldd /bin/cp => (0x00007fff6d9e5000) => /lib/x86_64-linux-gnu/ (0x00007f90de140000) => /lib/x86_64-linux-gnu/ (0x00007f90ddf37000) => /lib/x86_64-linux-gnu/ (0x00007f90ddd31000) => /lib/x86_64-linux-gnu/ (0x00007f90dd96d000) => /lib/x86_64-linux-gnu/ (0x00007f90dd700000) => /lib/x86_64-linux-gnu/ (0x00007f90dd4fb000)
    /lib64/ (0x00007f90de3b5000) => /lib/x86_64-linux-gnu/ (0x00007f90dd2dd000)

    Users can find the location of a library file by using the "whereis" command. For instance, users can type whereis libpng to find the PNG library.

    collier@Nacho-Linux:~$ whereis libpng
    libpng: /usr/include/libpng /usr/share/man/man3/libpng.3.gz

    Alternately, users can use ldconfig which is used to find needed libraries for the linker.

    collier@Nacho-Linux:~$ ldconfig -p | grep libpng (libc6,x86-64) => /lib/x86_64-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/ (libc6) => /lib/i386-linux-gnu/ (libc6) => /usr/lib/i386-linux-gnu/ (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/

    Further Reading

    1. Linux Filesystem Modules
Viewing 1 post (of 1 total)