AKDL DESIGN
2026-03-06 linux philosophy systems engineering

The Exposed Machine: Why Linux Lets You See Everything

A deep dive for engineers who want to understand their operating system

A few weeks ago I took an idle desktop from 120 watts to 61 watts. No third-party power management suite. No registry hacks pulled from a 2019 forum post with seventeen conflicting replies. No reboots into special modes. I wrote strings into files, and the hardware responded.

That sentence should sound unremarkable. But if you've spent time administering Windows machines, it sounds like magic - or at least like it should be harder than it was. The project became a lens through which I could see something I'd felt for years but hadn't articulated cleanly: Linux doesn't just let you control the machine. It expects you to. The interfaces are there on purpose, documented on purpose, and stable on purpose. The system was built by people who think like engineers, and it shows.

This isn't a tutorial. It's a reflection on why that power optimization project felt so different from doing the same work on other operating systems - and what that difference reveals about system design philosophy.


1. The Unix Philosophy: Everything Is a File

You've heard this before. "Everything is a file" gets trotted out in every intro-to-Linux course. But most explanations stop at "you can cat things," which misses the point entirely. It's not a metaphor. It's a literal architectural commitment with profound consequences.

When I ran this command to put a PCI device into auto power management:

$ echo auto > /sys/bus/pci/devices/0000:01:00.0/power/control

Here's what actually happened at the kernel level: my shell opened a file descriptor, wrote five bytes (a-u-t-o-\n), and closed it. The kernel's sysfs layer intercepted that write, matched it against the power/control attribute of the PCI device registered at address 0000:01:00.0, and called the device driver's power management callback. The driver negotiated a low-power state with the hardware. That's the whole mechanism. Five characters. One file write. The device changed power states.

If you come from electrical engineering, this is immediately familiar. It's memory-mapped I/O, the same pattern you use on a microcontroller when you write to a register at 0x40021018 to configure a GPIO pin. But instead of hex offsets into an address space, the addresses are filesystem paths. Instead of consulting a 900-page reference manual to find the right register, you ls a directory.

The real power of this commitment is composability. Because these interfaces are files, every tool that works on files works on hardware. You can cat a power state. You can grep across every device's configuration. You can write a shell script that iterates over PCI devices the same way it would iterate over log files. You can use watch to poll a sensor reading. You can use inotifywait to react to hardware events. No SDK. No API bindings. No COM objects. Just files.

# Check power management state of every PCI device. One line.
$ for dev in /sys/bus/pci/devices/*/power/control; do
    echo "$(cat "$dev") $(dirname $(dirname "$dev") | xargs basename)"
  done
auto 0000:00:00.0
on   0000:01:00.0
auto 0000:02:00.0
...

That loop would take dozens of lines of PowerShell and WMI queries on Windows, if it were possible at all. And it wouldn't be discoverable - you'd need to already know the WMI class name.

2. Sysfs: Your Hardware's API

/sys is where "everything is a file" gets concrete. It's a virtual filesystem - nothing on disk, generated entirely in memory by the kernel at boot. And it mirrors your actual hardware topology.

Every bus gets a directory. Every device on that bus gets a subdirectory. Every tunable parameter on that device gets a file. The hierarchy isn't arbitrary; it reflects how the silicon is actually wired. PCI devices live under /sys/bus/pci/devices/. USB devices under /sys/bus/usb/devices/. Block devices under /sys/block/. The structure is the documentation.

During the power project, I spent a lot of time in three corners of sysfs:

NVMe power management. An NVMe SSD at /sys/bus/pci/devices/0000:04:00.0/power/control. Write auto to that file. The kernel negotiates Active State Power Management (ASPM) with the device, the drive's controller enables clock gating on idle channels, and power draw drops by a few watts. The drive is still fully responsive - the latency to wake from a shallow power state is measured in microseconds. All from writing four characters.

CPU energy monitoring. Intel's Running Average Power Limit (RAPL) interface is exposed at /sys/class/powercap/intel-rapl:0/energy_uj. That file contains a running counter of microjoules consumed, sourced from MSR register 0x611 on the CPU. Read it twice with a known time interval and you have instantaneous power draw with milliwatt precision. No external power meter needed - the CPU is measuring itself and reporting it through the filesystem.

# Measure CPU package power draw over 1 second
$ e1=$(cat /sys/class/powercap/intel-rapl:0/energy_uj)
$ sleep 1
$ e2=$(cat /sys/class/powercap/intel-rapl:0/energy_uj)
$ echo "scale=2; ($e2 - $e1) / 1000000" | bc
8.34  # watts

Discrete GPU runtime PM. The 1080 Ti sitting in slot 0000:01:00.0 draws 15-20 watts at idle doing absolutely nothing. Write auto to its power/control file. The kernel puts it into PCI D3 state - essentially off, drawing milliwatts. Five bytes, written into a file, and a 250-watt graphics card goes to sleep.

Now compare this to the Windows experience. To check a PCI device's power state, you open Device Manager (GUI), expand a category, right-click a device, go to Properties, find the Power Management tab - if it exists, which it doesn't for all devices. To do it programmatically, you write a WMI query through a COM object, which means pulling in a scripting runtime, handling COM initialization, and parsing results from a schema you have to look up on Microsoft Learn. To do it for all devices at once, you need a script that's 40 lines minimum and fragile against WMI namespace changes between Windows versions.

The sysfs approach isn't just simpler. It's discoverable. I didn't need to know these interfaces existed in advance. I ran ls, saw a power/ directory, listed that, saw a control file, read it, and understood the interface. The filesystem is its own documentation browser.

3. Systemd: Declarative Service Management

Whatever your feelings about systemd - and people have feelings - the service management model is genuinely good. A unit file is a plain text INI file, usually under 15 lines, that declaratively describes what you want.

# /etc/systemd/system/powertune.service
[Unit]
Description=Set hardware power states at boot
After=sys-devices-pci0000:00.device

[Service]
Type=oneshot
ExecStart=/usr/local/bin/powertune.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

That's the entire file. It says: after PCI devices are enumerated, run this script once, remember that it ran, and do this on every normal boot. The dependency model is explicit. The execution model is obvious. You can read it and know exactly what will happen.

Two systemd features turned out to be critical for the power project:

Masking. systemctl mask bluetooth.service creates a symlink to /dev/null. Not "disabled" - impossible to start. No other service can pull it in as a dependency. No user can accidentally enable it. It's a hard guarantee that this thing will not run. Bluetooth was drawing a few watts and serving no purpose on a headless machine; masking it was surgical.

Socket activation. Instead of starting Docker's daemon at boot (where it sits consuming memory and CPU cycles whether or not you're using containers), you can tell systemd to listen on Docker's socket and only spawn the daemon when something connects. The daemon starts on first docker command, not at boot. For a machine that runs containers intermittently, this saves meaningful watts during idle periods.

$ systemctl mask bluetooth.service
Created symlink /etc/systemd/system/bluetooth.service -> /dev/null.

# That's it. Bluetooth cannot start. Not disabled. Impossible.

Windows services have services.msc, which is fine for basic start/stop operations. But there is no mask equivalent. You can set a service to "Disabled," but a system update can flip it back, or another service can still try to invoke it. "Delayed Start" exists, but it's just "start later" - not "start on demand." Socket activation doesn't exist in the Windows service model at all. These aren't feature gaps that can be worked around; they represent a fundamentally less expressive model of service management.

4. Udev: Hardware Events as One-Line Rules

Udev is the subsystem that handles device events - plugging in a USB drive, a PCI device enumerating at boot, a network interface appearing. And the way you interact with it is by writing rules. Plain text files. One rule per line.

The syntax takes about five minutes to learn: double-equals (==) matches conditions, single-equals (=) assigns actions. That's it. That's the whole language.

# /etc/udev/rules.d/10-power.rules

# When any PCI device appears, set it to auto power management
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"

# When WiFi hardware appears, immediately soft-block it
ACTION=="add", SUBSYSTEM=="rfkill", ATTR{type}=="wlan", ATTR{soft}="1"

# When an NVMe device appears, enable ASPM
ACTION=="add", SUBSYSTEM=="pci", ATTR{class}=="0x010802", ATTR{power/control}="auto"

That WiFi rule is worth pausing on. It says: when the kernel detects a wireless device being added (at boot or hotplug), immediately set its soft-block attribute to 1, disabling it. The machine doesn't have WiFi because I don't want it to have WiFi. Not because I uninstalled a driver, not because I flipped a BIOS switch, but because I wrote a seven-word policy and the kernel enforces it on every boot.

These rules fire at boot for every device that enumerates, and they fire at runtime for hotplugged devices. Same rules, same behavior, every time. No timing issues, no "did the script run before or after the driver loaded" ambiguity.

To accomplish the equivalent on Windows, you'd need a combination of PowerShell scripts, Task Scheduler tasks triggered by WMI events, and possibly Group Policy Objects. Each of these systems has its own configuration format, its own failure modes, and its own documentation scattered across different parts of Microsoft Learn. There is no unified, user-facing rules engine for hardware events. The capability exists somewhere in the kernel, but it's not exposed - which, for practical purposes, means it doesn't exist.

5. The Man Page Culture

This is the part that's easy to overlook because it's not technical, but it might be the most important.

When I needed to understand how systemctl mask worked, I ran man systemctl. The answer was there, on my machine, version-matched to the exact binary I was running. Not a blog post from 2019 that might describe a different version. Not a Stack Overflow answer where the top-voted reply works on Ubuntu 18.04 but not on my system. The man page is the specification, and it ships with the tool.

$ man systemctl
# SYSTEMCTL(1)                 systemctl                 SYSTEMCTL(1)
#
# ...
# mask NAME...
#     Link the unit file to /dev/null, making it impossible to
#     start. This is a stronger version of disable, since trying
#     to start the unit manually or as a dependency will fail.
# ...

This sounds mundane until you've spent an afternoon trying to figure out how a Windows registry key actually works. The registry is the backbone of Windows configuration, and large portions of it are sparsely documented or not documented at all. Microsoft Learn pages sometimes describe behavior that changed two versions ago. Third-party documentation is a labyrinth of conflicting advice across different Windows editions.

Linux's man page culture isn't just about documentation quality. It's about a philosophical commitment: the interface is public, and we will tell you how it works. Every sysfs attribute, every systemd directive, every udev keyword has a man page or a kernel documentation file. The system doesn't have secret internal APIs that work better than the public ones. The public API is the internal API.

The result is that when you're working on a Linux system, you are never reverse-engineering. You are reading documentation and applying it. The gap between "how it works" and "how you use it" is effectively zero, because they're the same thing.

6. Why It Feels Not Hacky

After the power optimization project was done - 120 watts down to 61 watts idle, with all services running and no performance impact - I looked at everything I'd changed and realized something: every single change used a documented, public, stable interface that was designed for exactly that purpose.

Writing to power/control? That's the kernel's power management API. It's in the documentation. It's been stable for over a decade. Creating a udev rule? That's the device management system working as intended. Masking a systemd service? That's a first-class operation with its own verb. Reading energy counters from RAPL? Intel designed that MSR specifically to be read by operating system power management software, and Linux exposes it at a well-known filesystem path.

None of it was a hack. None of it relied on undocumented behavior, side effects, or tricks. And that's the thing that "feels right" about Linux - you are not fighting the system. You are operating it.

Unlike sometimes when we run Windows, and we just do a bunch of workarounds and stuff. This is all straightforward.

That quote captures something real. On Windows, power optimization involves downloading third-party utilities that poke at undocumented APIs. It involves editing registry keys you found on a Tom's Hardware thread from 2017, hoping they still apply to your Windows version. It involves learning that "High Performance" and "Balanced" power plans have hidden sub-settings that differ between laptop and desktop SKUs in ways that aren't documented anywhere. The knowledge is scattered, version-dependent, and often wrong.

On Linux, the knowledge is in /sys. It's in man pages. It's in files you can read, modify, and script against. The interfaces are first-class citizens of the operating system, not afterthoughts bolted onto a system that would prefer you didn't look too closely.

The best analogy I can offer is from embedded systems. Imagine two microcontrollers. One has a complete, public register map. Every peripheral is documented. You can read any register, write any configuration, and the behavior is specified. You can build tools, write drivers, and debug with confidence because the system is transparent.

The other microcontroller has a register map where half the registers are marked "reserved." The documented ones sometimes behave differently than described. The vendor provides a proprietary HAL library - precompiled, closed source - that's the "supported" way to configure the hardware. You can use the HAL, but you can't see what it's doing. When something goes wrong, you can't debug below the HAL layer. The capability is in the silicon, but it's not exposed to you.

Linux is the first microcontroller. The system trusts you with the hardware. It gives you the register map - as a filesystem - and says: here, this is how it works, do what you need to do. The interfaces aren't hidden. They aren't proprietary. They aren't going to change out from under you without deprecation warnings. They are yours.


The power project was small. A few hours of work, a few config files, a measurable result. But it crystallized something I've been thinking about for years: the reason Linux appeals to engineers isn't the command line, or the free-as-in-beer aspect, or the customizability for its own sake. It's that the system was designed by people who believe that if a machine can do something, the person operating it should be able to ask for it clearly.

Every file in /sys is an invitation. Every man page is a handshake. Every udev rule is a policy you wrote and the kernel honors. The machine is exposed - not in the sense of being vulnerable, but in the sense of being visible. You can see every gear turning. And when you reach in to adjust one, there's a documented, stable, purposeful way to do it.

That's why it feels right. Not because it's powerful, though it is. Not because it's free, though it is. Because it's honest. The system is exactly what it appears to be, and it appears to be everything it is.

Back to home