1

along with the previous main Q, I also have another one why can't we write in /usr even though they can be new software packages added to our system, does that mean it only saves info and data on first-time apps and programs only and for new ones we can use another one like /opt

Souha
  • 11

1 Answers1

2

The /proc directory was originally used to expose internal information about processes (hence the name) to the user. On most modern Unix-like systems, including Linux, the filesystem mounted on this mount point is a virtual filesystem. In Linux and several other Unix-like systems, this virtual filesystem is called procfs.

Because procfs already existed and was already capable of exposing internal kernel information to the user, over time, it was used to expose all kinds of other information that has nothing to do with processes. For example, networking information, information about the hardware and the CPU, information about block devices, and so on.

Furthermore, there was no standard for how to expose this information to the user. Some developers put all the information into a single file, some used a separate file for each bit of information. And so on.

The Linux kernel developers decided that this was too much of a mess. So, they created sysfs, which is mounted at /sys. sysfs, like procfs, exposes internal information from the kernel to the user. However, for sysfs, the developers imposed a strict set of rules for how to expose this information. In fact, in many cases, the developer simply registers their information with the kernel and the kernel itself controls how this information is exposed. This guarantees that information from different developers and different parts of the kernel is exposed in a similar way.

So, in summary:

  • /proc was originally intended to expose internal information about processes, but over time became a dumping ground to expose any kind of internal information from the kernel.
  • /sys was created to expose this information in a standardized, structured, way.

However, for reasons of backwards-compatibility, all the information that used to be exposed in /proc still has to be there, until the end of time. New information should be exposed in /sys in a structured manner, following the rules of sysfs.