What is lib directory in linux

What is the difference between /lib and /usr/lib and /var/lib?

What is the difference between /lib and /usr/lib and /var/lib ? Some of the files are symbolic links that «duplicate» content of other directories.

2 Answers 2

Someone else can probably explain this with much more detail and historical reference but the short answer:

/lib

is a place for the essential standard libraries. Think of libraries required for your system to run. If something in /bin or /sbin needs a library that library is likely in /lib .

/usr/lib

the /usr directory in general is as it sounds, a user based directory. Here you will find things used by the users on the system. So if you install an application that needs libraries they might go to /usr/lib . If a binary in /usr/bin or /usr/sbin needs a library it will likely be in /usr/lib .

/var/lib

the /var directory is the writable counterpart to the /usr directory which is often required to be read-only. So /var/lib would have a similar purpose as /usr/lib but with the ability to write to them.

Just to improve a bit — it all comes from Filesystem Hierarchy Standard. The definition is a bit old-ish now but still offers interesting insight. pathname.com/fhs/pub/fhs-2.3.html

This answer is at least 15 years late, yeah, «historically» it’s correct but Linux distros haven’t had /bin /sbin and /lib for many years now and all three are linked to the appropriate /usr directories. And /var/lib normally holds transcient data, you may as well delete completely and the system won’t be affected. Lastly it’s probably the 150th time this question has been asked. Dunno why people jump to answer it again and again.

@ArtemS.Tashkinov Sorry, but there’s a whole lot of inaccuracies in your comment. «15 years» is way off, Fedora made the move to /usr in 2012 and it certainly wasn’t the last major distro to do so (if not the first). /var/lib is definitely not for transient data, at least not on most distros. Deleting it is going to have disastrous consequences on a typical system (destroying the yumdb/rpmdb and breaking the package manager with no way to repair it, nuking the default storage location of various SQL databases or VMs with precious data, etc.)

Читайте также:  Оконные менеджеры linux ubuntu

noteworthy: «as it sounds, a user based directory» — usr sounds like «user», but it actually stands for Unix System Resources

@kubi That smells of Folk Etymology or Convenient Backronym to me; it’s not even a good description of its role. Wikipedia cites these notes from Dennis Ritchie describing the origin as «a directory ‘/usr’ which contains all user’s directories, and which is stored on a relatively large, but slow moving head disk».

Files in /lib and /usr/lib are supposed to be mostly read only and identical between systems. (If it was a container image, they could be fully read only and shared between systems; on a stand alone system, they need to be writable to install updates.)

Files in /var are specific to the local system and frequently contain data that is generated by system operation.

Typically distribution versions of templates for config files can be found in /usr/lib and can be used to create localized versions of config files in /etc or possibly /var .

I’m not sure why there would be duplicate files between /lib and /usr/lib , more likely they are symlinks and not duplicates. (There are no such files on my current system, and only one symlink.)

Historically directories like /usr/lib /usr/bin were actually created because /usr was on a separate disk and things were put there because /bin and /lib were on the root disk which was too small to hold everything, and what was left on the root disk were things critical to boot far enough to mount /usr . Of course, this concept is obsolete, and there is a movement to merge them.

Источник

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 добавление принтера windows

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.

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.

Читайте также:  Vmware linux установить vmware tools

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

Источник

what do these directory is used for in linux? etc/ bin/ and lib/ [closed]

You can read all about the details by looking up the filesystem hierarchy standard, but in a nutshell:

  • /etc : Configuration information
  • /lib : Libraries
  • /bin : Program binaries that are important to the functioning of the system. (Non-essential binaries are generally found in /usr/bin ; these are generally installed with the operating system distribution. Programs installed after OS installation are generally stored in /usr/local/bin .)
  • etc -> To keep configuration files
  • lib -> To keep libraries that can be used by installed software or other softwares in your system.
  • bin -> Binary files

hi @shadyabhi, do you happen to know /var/log/messages this folder too? what is it used for? im trying to find it in my system, it cant be found

/var/log/messages That will be a file & it may exist or it may not depending on how syslogging is configured on your system. I can’t say anything about why it isn’t present without getting your configuration file for your syslogging program.

@ruggedbuteducated /var/log/ is a directory generally used for storing logs. All programs generally write to /dev/log file socket which is picked up by syslog program such as syslog-ng or rsyslog etc etc. Then this syslog program reads from that file socket and depending on which program is sending logs, write to a appropriate file under /var/log/ generally. Generally, messages is present and programs write to it most. You can check what are your recent files in /var/log by using ls -ltr /var/log . It could be everything.log or messages.log etc etc.

bin — Contains binary files to configure the operating system.(In the binary format)_________ etc — contains machine specific configuration files in editable format. _________ lib -> contains shared binary files which are shared by bin and sbin.

Источник

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