We already explained other important system folders like /bin, /boot, /dev, /etc etc folders in our previous posts. Please check below links for more information about other stuff which you are interested. In this post, we will see what is /lib folder all about.
What is /lib folder in Linux?
The lib folder is a library files directory which contains all helpful library files used by the system. In simple terms, these are helpful files which are used by an application or a command or a process for their proper execution. The commands in /bin or /sbin dynamic library files are located just in this directory. The kernel modules are also located here.
Taken an example of executing pwd command. It requires some library files to execute properly. Let us prove what is happening with pwd command when executing. We will use the strace command to figure out which library files are used.
root@linuxnix:~# strace -e open pwd open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3 /root +++ exited with 0 +++ root@linuxnix:~#
If you observe, We just used open kernel call for pwd command. The pwd command to execute properly it will require two lib files.
Contents of /lib folder in Linux
As said earlier this folder contains object files and libraries, it’s good to know some important subfolders with this directory. And below content are for my system and you may see some variants in your system.
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 is a folder which contains hardware firmware code.
What is the difference between firmware and drivers?
Many devices software consists of two software piece to make that hardware properly. The piece of code that is loaded into actual hardware is firmware and the software which communicate between this firmware and kernel is called drivers. This way the kernel directly communicate with hardware and make sure hardware is doing the work assigned to it.
/lib/modprobe.d – Configuration directory for modprobe command
/lib/modules – All loadable kernel modules are stored in this directory. If you have more kernels you will see folders within this directory each represents a kernel.
/lib/hdparm – Contains SATA/IDE parameters for disks to run properly.
/lib/udev – Userspace /dev is a device manager for Linux Kernel. This folder contains all udev related files/folders like rules.d folder which contain udev specific rules.
The /lib folder sister folders: /lib32 and /lib64
These folders contain their specific architecture library files. These folders are almost identical to /lib folder expects architecture level differences.
Other library folders in Linux
/usr/lib – All software libraries are installed here. This does not contain system default or kernel libraries.
/usr/local/lib – To place extra system library files here. These library files can be used by different applications.
/var/lib – Holds dynamic data libraries/files like the rpm/dpkg database and game scores.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix- June 29, 2020
- FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018