Linux lib modules directory

Linux Binary Directories Explained

Binaries are files that contain compiled source code (or machine code). Binary files are the files which contain compiled source code (or machine code). They are also called executable files because they can be executed on the computer.

Binary directory contains following directories:

The /bin directory contains binaries for use by all users. The ‘/bin’ directory also contains executable files, Linux commands that are used in single user mode, and common commands that are used by all the users, like cat, cp, cd, ls, etc. According to the FHS the /bin directory should contain /bin/cat and /bin/date (among others). The ‘/bin’ directory doesn’t contain directories.

Other /bin directories

You can find a /bin subdirectory in many other directories. A user named Amy could put her own programs in /home/amy/bin. Some applications, often when installed directly from source will put themselves in /opt. A samba server installation can use /opt/samba/bin to store its binaries.

The /sbin contains binaries to configure the operating system. The ‘/sbin’ directory also contains executable files, but unlike ‘/bin’ it only contains system binaries which require root privilege to perform certain tasks and are helpful for system maintenance purpose. e.g. fsck, root, init, ifconfig, etc. Many of the system binaries require root privilege to perform certain tasks.

The ‘/lib’ directory contains shared libraries which are often used by the ‘/bin’ and ‘/sbin’ directories. It also contains kernel module. These filenames are identable as ld* or lib*.so.*. For example, ld-linux.so.2 and libfuse.so.2.8.6. Below is an example of the partial contents of /lib.

$ ls /lib/libc*

/lib/libc-2.5.so /lib/libcfont.so.0.0.0 /lib/libcom_err.so.2.1

/lib/libcap.so.1 /lib/libcidn-2.5.so /lib/libconsole.so.0

/lib/libcap.so.1.10 /lib/libcidn.so.1 /lib/libconsole.so.0.0.0

/lib/libcfont.so.0 /lib/libcom_err.so.2 /lib/libcrypt-2.5.so

1) /lib/modules: The ‘/lib/modules’ stores kernel modules and has a directory for each installed kernel. Typically, the Linux kernel loads kernel modules from /lib/modules/$kernel-version/. Modules are meant to use extra hardware support without making a new kernel.

Читайте также:  Переименовать файл командная строка linux

2) /lib32 and /lib64: We currently are in a transition between 32-bit and 64-bit systems. During compilation time of libraries, you’ll encounter through the directories named ‘/lib32’ and ‘/lib64’ which will clarify register size to be used. A 64-bit system may have compatibility for 32-bit binary.

The term ‘opt’ is short for optional. Its main purpose is to store optional application software packages. In many cases this is software from outside the distribution repository. Add-on applications from individual vendors should be installed in ‘/opt’. In some systems ‘/opt’ is empty as they may not have any add-on application. A large package can install all its files in /bin, /lib, /etc subdirectories within /opt/$packagename/. If for example the package is called wp, then it installs in /opt/wp, putting binaries in /opt/wp/bin and man pages in /opt/wp/man.

If you need any further help please reach our support department.

Источник

Linux directory structure: /lib explained

The Linux Juggernaut

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.

Читайте также:  Ставим linux на телефон

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.

Читайте также:  Linux zip создать многотомный архив

/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.

Surendra Anne

Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.

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

Источник

Оцените статью
Adblock
detector