Homepage › Forums › Articles › Operating Systems › Linux › Linux Libraries (Paths, Files, and Commands)
This topic was published by DevynCJohnson and viewed 1878 times since "". The last page revision was "".
- Topics - 437
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-linux.so, ld-linux.so*, ld.so, 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. "ld.so" and its related files manage a.out binaries while "ld-linux.so" (and others) is used by ELF binaries. These libraries are typically found in /lib/.
- libc - Standard C Library (http://man7.org/linux/man-pages/man7/libc.7.html)
- 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
- /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.
- /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.
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
/etc/ld.so.conf.d/ is a directory that contains a list of configuration files that list the library paths for each architecture type.
collier@Nacho-Linux:/etc/ld.so.conf.d$ ls fakechroot-x86_64-linux-gnu.conf fakeroot-x86_64-linux-gnu.conf i386-linux-gnu.conf i386-linux-gnu_GL.conf i686-linux-gnu.conf libc.conf x86_64-linux-gnu.conf x86_64-linux-gnu_EGL.conf x86_64-linux-gnu_GL.conf x86_64-linux-gnu_mirclient8driver.conf zz_i386-biarch-compat.conf zz_x32-biarch-compat.conf collier@Nacho-Linux:/etc/ld.so.conf.d$ cat ./x86_64-linux-gnu.conf # Multiarch support /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
Users can see a list of libraries needed by an executable by running the "ldd" command. In a terminal/command-line, run
ldd EXECUTABLE_PATHto 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 linux-vdso.so.1 => (0x00007fff6d9e5000) libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f90de140000) libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007f90ddf37000) libattr.so.1 => /lib/x86_64-linux-gnu/libattr.so.1 (0x00007f90ddd31000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f90dd96d000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f90dd700000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f90dd4fb000) /lib64/ld-linux-x86-64.so.2 (0x00007f90de3b5000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f90dd2dd000)
Users can find the location of a library file by using the "whereis" command. For instance, users can type
whereis libpngto 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 libpng12.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libpng12.so.0 libpng12.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpng12.so.0 libpng12.so.0 (libc6) => /lib/i386-linux-gnu/libpng12.so.0 libpng12.so.0 (libc6) => /usr/lib/i386-linux-gnu/libpng12.so.0 libpng12.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libpng12.so
- Standard C Libraries - http://dcjtech.info/topic/standard-c-libraries/
- Standard C Library Headers - http://dcjtech.info/topic/standard-c-library-headers/
- GNU-Toolchain - http://dcjtech.info/topic/gnu-toolchain/
- Cairo Graphics Library - http://dcjtech.info/topic/cairo-graphics-library/
- Static, Shared Dynamic, and Loadable Linux Libraries - http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
- FHS - http://www.pathname.com/fhs/