What is in /dev, /proc and /sys?

After mount there are listed some filesystems. I need to know what’s in the /dev, /proc and /sys. Some examples would be great!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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


Footnotes:

  1. There are also several /dev entries that do not correspond to hardware devices, such as /dev/null, /dev/random, and /dev/tty. These are virtual devices that let user space programs talk to other parts of the kernel besides the running drivers in a device-like fashion.
  2. As a rule, /sys tends to be more strictly organized than /proc, since /sys mirrors the internal kernel data structures that manage the system’s resources, whereas /proc grew organically over many years, and old questionable design decisions can’t change now because there are programs using those old interfaces. /sys started out with a clearer design, and doesn’t have to drag around as much historical baggage as /proc.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x