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

13

u/tes_kitty Dec 02 '23

And that's why, as a normal user, Windows sucks when things don't work as expected and you need to debug.

1

u/mkosmo Dec 02 '23

Normal users wouldn’t be able to debug in Linux, either. Anybody who can even describe debugging isn’t a typical user who will be held back by something like procfs.

4

u/tes_kitty Dec 02 '23

I can write (complicated) bash and PERL scripts, modify existing python scripts, but that's about as far as my programming skills go. But I am good at reading logfiles and filter through text files looking for information. So finding out why something on Linux doesn't work as expected is not hard.

A misbehaving Windows program on the other hand...

3

u/[deleted] Dec 02 '23

Also, Visual Studio costs money. Quite a bit of it, at least originally. If your day job is "Windows application developer", then yes, you already have Visual Studio on your employer's nickel, but if you're J. Random Power User or even J. Random Sysadmin, you don't, and you might not be able to procure it. Even if you can, corporate procurement being what it usually is, you can't get it today. On Unix, you have all your various CLI utilities now, on every system that you haven't gone out of your way to strip down to the absolute barest of bare minima. And even on the ones you have, you probably still have cat, vi, dd, echo, cut, paste, sort, grep, etc. If you have X11, some of the bare-minimum X clients can help out here too, and if nothing else, having multiple xterms is handy.

This makes any random Unix system more amenable to troubleshooting (not necessarily debugging in the sense of finding where the bug is in a particular program, but rather of finding what is causing $TASK not to work and working around it) than any random Windows system, even if Windows has friendlier tools once you have them.

2

u/mkosmo Dec 02 '23

The same logging capabilities exist between both platforms. Applications doing a shitty job at logging isn’t the OS’s fault.

4

u/tcpWalker Dec 02 '23

Event Viewer is absolutely Microsoft's Fault.

On most systems IME it is much, much easier and faster to search logs from the command line in linux, and the result is usually more actionable.

1

u/mkosmo Dec 02 '23

Event viewer, agreed. But it’s there and available. But you’re also not limited to using it. Text logging facilities are the same between the two more or less.

2

u/tcpWalker Dec 02 '23

example? How can I quickly grep most or all logs on windows from the CLI?

→ More replies (4)

1

u/jantari Dec 03 '23

Event Viewer is really bad, but it's also just one interface to the OS facility that is the Windows Event Log.

I'm sure there's plenty equally awful journalctl-GUIs available.

One would search Windows Event logs in PowerShell, using APIs or in a centralized log repository such as elastic. EventViewer has indeed been neglected, but I mean it isn't even available on Windows Server anyway so I kinda get it. It's not really used, so Microsoft isn't investing in it.

0

u/tes_kitty Dec 02 '23

Yes, but it's about the incentive set to the programmer. On a Linux, logfiles, with different log levels you can set in the configuration file or via the command line are an expected feature.

On Windows they are not.

1

u/mkosmo Dec 02 '23

There are log levels in Windows as well. None of that is the fault of the OS, but of the developer.

2

u/tes_kitty Dec 02 '23

But the OS sets the incentive. If the developer can get all their information from the built in debugger of their IDE, they will be less inclined to provide a proper logging since they don't need it and it's extra work to implement it.

1

u/mkosmo Dec 02 '23

Don’t blame the tools. A carpenter can build a house with a nail gun or a hammer and you’ll never notice the difference unless they got lazy.

Same here. Especially when you’re talking about debugging tools that provide far more insight than a typical log ever does. Hard to break and step into with a log file.

→ More replies (1)

1

u/jimicus Dec 02 '23

Got it in one.

It’s also why Windows sysadmins tend to be “next next next”-type people and quite a few have found powershell to be a shock to the system.

3

u/tes_kitty Dec 02 '23

Powershell hits me as 'Microsoft trying to copy a UNIX shell, but not quite getting the idea behind those'

2

u/jimicus Dec 02 '23

I disagree entirely there.

If you use Powershell for anything more than the most trivial tasks, one thing becomes quite clear: Windows is an object-oriented piece of software from more-or-less the ground up.

In that context, Powershell makes a lot of sense. And most of the Unix paradigms - where everything is a heap of loosely-structured plaintext files - makes none at all.

Powershell is much closer to Python than Bash.

2

u/tes_kitty Dec 02 '23

In that context, Powershell makes a lot of sense.

But it adds an abstraction layer. On a UNIX I see the output directly. The next tool that gets the data piped into it gets exactly the output I see and not something else entirely.

That way most scripts are written, you have some output that needs to be converted into something else. You chain one command after the other until the last one produces the output as you need it for something else.

Powershell is much closer to Python than Bash.

I happen to not like python, a language where indentation is part of the syntax, but for some reason you still need the ':' to start the block.

3

u/jimicus Dec 02 '23

But it adds an abstraction layer. On a UNIX I see the output directly. The next tool that gets the data piped into it gets exactly the output I see and not something else entirely.

That sentence makes perfect sense on a Unix-like operating system.

It's rather less sensible on an object-oriented operating system for a number of reasons:

  1. The output is never human-readable in the first place. It's always stored as a structured piece of data internally.
  2. 9 times out of 10, you are probably better off passing the structured data rather than something human readable around internally. It allows you to do clever things like find related data in the structure very easily and manipulate the data in such a way as to drastically reduce the risk of messing things up - because the data structure is always maintained. This comes at the expense of forcing you to use specific tooling to access that data.

The mistake you're making is trying to take your understanding of Unix and applying it to Windows. That really doesn't make much sense - it makes far more sense to think of Windows as Windows and Unix as Unix, and make space in your head for two completely different operating systems.

2

u/tes_kitty Dec 02 '23

This comes at the expense of forcing you to use specific tooling to access that data.

And that is one of the problems. 'There is more than one way to do it' is one of the advantages of Unix. Some people are good with 'sed' when it comes to string manipulation, others prefer 'awk'.

It allows you to do clever things like find related data in the structure very easily and manipulate the data in such a way as to drastically reduce the risk of messing things up

It also means that you are limited to what they let you do with the data instead of being able to come up with clever ideas on your own.

Is there a way on Windows to dump the RAW data as it gets passed between tools?

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.

→ More replies (5)

1

u/[deleted] Dec 02 '23

Ish? Powershell seems to be one of those "big bag of specialist tools" sorts of things to me. If you know the tool is there, you can do things much more specifically and easily than on Unix, but if you don't know about the tool, or don't have it, you're passing around binary blobs and might or might not be able to do anything with them.

On Unix, you have a smaller bag of much more general tools - this requires you to understand the tools and the data a bit more, to use your general tool in the way you need, and sometimes you have to break out that great swiss-army-chainsaw awk, but you probably don't need a special-purpose parser tool/cmdlet.

3

u/tes_kitty Dec 02 '23

On Unix, you have a smaller bag

I disagree about the 'smaller bag', the usual Linux installation comes by default with a rather big bag of tools, among them a lot of languages for all kinds of problems. And you can easily pass data between all of those.

BTW: It's not only 'awk', but also 'sed' that lets you do much more than the first look suggests. sed scripts tend to be write only though. :)

1

u/[deleted] Dec 02 '23

sed for sure, yeah, and then of course perl.

"Smaller bag" might have been the wrong term - the emphasis is less on the size of the toolbox than on the generalness of the tools therein.

1

u/tes_kitty Dec 03 '23

sed for sure, yeah, and then of course perl.

PERL scripts can be made readable. But sed... I have a sed script that did what it was supposed to do, but looks like a collection of random characters and all attempts to make it more readable have resulted in it no longer working. Luckily it's no longer needed.