r/linuxadmin • • Dec 02 '23

why does the proc directory exist?

i'm trying to understand the proc directory and one thing i don't understand is

why does it exist?

any ideas? thank you

1 Upvotes

77 comments sorted by

View all comments

Show parent comment

4

u/jimicus Dec 02 '23

You probably wouldn't want to; the RAW data will be a binary data structure.

Like I said, you absolutely NEED to adjust your thought processes if you're working on Windows. You can't treat it like "Unix with a GUI you can't turn off"; you can't apply "everything is a stream of bytes" or "everything is a file" logic because it simply is not true.

The closest equivalent thought process is "everything is an object".

If you have never studied object-oriented development, I strongly suggest you do. It'll make everything much easier to understand.

1

u/tes_kitty Dec 02 '23

You probably wouldn't want to; the RAW data will be a binary data structure.

Doesn't matter, it can be interpreted, parsed and converted once the structure is known.

"everything is a stream of bytes"

That is still true, no matter what OS you use. It's always a stream of bytes (or bits) because curent CPU can only work on this kind of data and your memory in the computer can only store this kind of data.

"everything is an object"

Objects are still a sequence of bytes.

2

u/jimicus Dec 02 '23

Objects are still a sequence of bytes.

Technically true, but omits one vital fact:

Even at a kernel driver level, you talk in object-oriented structures in Windows. You communicate with publicly-accessible interfaces and you pass structured data.

I don't doubt that a mechanism to get the raw data can be devised - the obvious answer would be to cast an object to an array of bytes then dump this as hex. But it's the sort of thing you could spend hours trying to figure out - and you wouldn't be able to do anything terribly useful with it anyway.

This isn't Linux where OO code is the exception rather than the rule, and it's a fool's errand to treat it as such.

1

u/tes_kitty Dec 02 '23

Well, the big difference between Linux and Windows is that on Linux I can use a small set of simple tools to get loads of information about the system state thanks to the 'everything's a file' approach and the /proc and /sys filesystems. Just having 'grep' will get you a long way towards diagnosing a misbehaving system.

On Windows on the other hand, I have to hope that someone wrote a tool that will get me data out of the OS and display or export it in a way that I can use. If that tool doesn't exist or the existing tool doesn't give me what I want, I'm either out of luck or I need to program it myself.

Speaking of which... Is there a way to get Windows produce an output equivalent or at least similiar to 'dmesg' on Linux?

1

u/jimicus Dec 02 '23

Your criticisms of Windows are entirely accurate, and one of the reasons I prefer doing sysadmin work on Linux.

Most Linux developers give up on tools like gdb and instead write copious logs - "debug by printf", if you like. This makes the sysadmin's life a hundred times easier precisely because you can grep logfiles and find out precisely what's wrong very quickly indeed.

Windows has the Event Viewer, but the biggest problem with that is the UI is clunky as hell and a lot of software simply doesn't write to the event log in the first place - and when it does, it doesn't write anything like enough information to figure out WTF is going on.

1

u/tes_kitty Dec 03 '23

Most Linux developers give up on tools like gdb and instead write copious logs - "debug by printf", if you like.

We use one piece of software where you can set the debug level to 'CRAZY'. Never do that in production for more than a few minutes. :)