Everything in Linux is presented as files and folders – even devices – even your printer.

And that is also how almost everything is read-write-accessed – as files.

/dev, /proc and /sys are “virtual (pseudo) filesystems” (not existing on harddisk, but only in RAM – so they do not consume any harddisk space and are completely created on boot).

Someone says:

/proc is one that maps into processes

/sys doesn’t interact with individual processes, but the system and kernel as a whole.

/proc used to be kernel and process interface.

Since kernel 2.5/2.6 the kernel-interface was moved to /sys, because /proc got cluttered with lots of non-process related information.

The /dev tree contains device nodes, which gives user space access to the device drivers in your OS’s running kernel.¹ All POSIX type OSes have a /dev tree.

The /proc tree originated in System V Unix, where it only gave information about each running process, using a /proc/$PID/stuff scheme. Linux greatly extended that, adding all sorts of information about the running kernel’s status. In addition to these read-only information files, Linux’s /proc also has writable virtual files that can change the state of the running kernel. BSD type OSes generally do not have /proc at all, so much of what you find under here is non-portable.

The intended solution for this mess in Linux’s /proc is /sys. Ideally, all the non-process information that got glommed into the /proc tree should have moved to /sys by now, but historical inertia has kept a lot of stuff in /proc. Often there are two ways to effect a change in the running kernel: the old /proc way, kept for backwards compatibility, and the new /sys way that you’re supposed to be using now.² (src)

Example Data:

tree -d /proc > proc.example.debian8.txt
proc.example.debian8.txt

(if you see strange characters in Firefox -> View -> Text-Encoding -> Unicode)

tree -d /sys > sys.example.debian8.txt

sys.example.debian8.txt

(if you see strange characters in Firefox -> View -> Text-Encoding -> Unicode)

dev.example.debian8.txt

(if you see strange characters in Firefox -> View -> Text-Encoding -> Unicode)

displaying the whole directory structure as a tree from Debian8.8 (Linux debian 3.16.0-4-686-pae #1 SMP Debian 3.16.43-2 (2017-04-30) i686 GNU/Linux).

 

Sysfs is a RAM based file system. (it only exists in RAM, not on harddisk)

This is how programs talk to the Linux kernel and modules/drivers (take inputs from the user space to control run-time (non permanent) settings).

By default, sysfs is compiled in the Linux kernel.

It is designed to export the kernel data structures and their attributes from the kernel to the user space, which then avoids cluttering the /proc file system.
The advantages of sysfs over procfs are as follows:

  • A cleaner, well-documented programming interface
  • Automatic clean-up of directories and files, when the device is removed from the system
  • The enforced one item per file rule, which makes for a cleaner user interface

The ‘one item per file’ rule mandates that in each file of sysfs, there will be only one value that can be put in or read from it. This feature really makes it a cleaner interface.

Links:

http://landoflinux.com/linux_procfs_sysfs.html

http://opensourceforu.com/2015/05/talking-to-the-kernel-through-sysfs/

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin