What does lib mean in linux?

09-11-2023

In linux, lib is the library file directory, which contains all the library files that are useful to the system. A library file is a file that an application, command or process needs to execute correctly. Almost all applications need to use shared library files located in the lib directory, and the function of lib is similar to that of DLL files in Windows.

Lib is the abbreviation of Library. This directory contains the most basic dynamic connection shared library of the system, and its function is similar to the DLL file in Windows. Almost all applications need to use these shared libraries.

The /lib folder is the library file directory, which contains all the library files that are useful to the system. Simply put, it is a file that an application, command or process needs to execute correctly. The dynamic library files of commands in the /bin or /sbin directory are in this directory. The kernel module is also here.

Take pwd command execution as an example. Executing it requires calling some library files. Let's explore what happened when the pwd command was executed. We need to use the strace command to find out the called library file.

Example:

root@linuxnix:~# strace -e open pwdopen("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3/root+++ exited with 0 +++root@linuxnix:~#

If you notice, you will find that the execution of the pwd command we use requires calling two library files.

Internal information of /lib folder in Linux

As mentioned before, this folder contains the target file and some library files, and it would be great if you could know some important sub-files of this folder. The contents listed below are based on my own system, which may be different for yours.

root@linuxnix:/lib# find . -maxdepth 1 -type d./firmware./modprobe.d./xtables./apparmor./terminfo./plymouth./init./lsb./recovery-mode./resolvconf./ crda./modules./hdparm./udev./ufw./ifupdown./systemd./modules-load.d

/lib/Firmware-This folder contains some hardware and firmware codes.

What is the difference between hardware and firmware?

In order to make the hardware run normally, many equipment software consists of two parts. Firmware refers to the part of code loaded into actual hardware, and the software used for communication between firmware and kernel is called driver. In this way, the kernel can communicate directly with the hardware and ensure that the hardware completes the work according to the instructions of the kernel.

/lib/modprobe.d-configuration directory of modprobe command.

/lib/modules-All loadable kernel modules are stored in this directory. If you have more than one kernel, you will see the directory representing the American kernel under this directory.

/lib/hdparm-contains parameters for the correct operation of SATA/IDE hard disk.

/lib/udev-user space /dev is the Linux kernel device manager. This folder contains all udev-related files and folders. For example, rules.d contains udev specification files.

Expand knowledge:

Sister folders of /lib: /lib32 and /lib64.

These two folders contain specially structured library files. They are almost the same as the /lib folder, except for the differences at the schema level.

Linux other library files

/usr/lib-All software libraries are installed here. But it does not include the system default library file and kernel library file.

/usr/local/lib-Place additional system files. These libraries can be used in various applications.

/var/lib-Libraries and files that store dynamic data, such as rpm/dpkg data and game records.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us