Table of Contents
Understanding `/sys`
The /sys directory is a special part of the Linux filesystem that exposes information and controls for the running kernel in a structured, file based way. It is not a normal directory stored on disk. Instead, it is part of a virtual filesystem that the kernel provides in memory.
When you browse /sys, you are effectively looking directly into how the kernel sees your hardware devices, drivers, and some system settings.
sysfs and the virtual nature of `/sys`
The filesystem mounted on /sys is called sysfs. It is typically mounted automatically when the system boots. Since it is virtual, the files you see there do not consume disk space, and their contents are generated by the kernel when you read them.
If you open a text file in /sys with a command like cat, the kernel returns up to date information at that moment. If you write to certain files in /sys, you are asking the kernel to change a parameter or control a feature. Because of this, writing incorrect values can have immediate and sometimes harmful effects.
Never experiment randomly by writing to files in /sys. Changes here affect the live kernel and hardware behavior.
How `/sys` is organized
The /sys tree is organized to reflect relationships between devices, drivers, and kernel subsystems. The exact layout can vary slightly between kernel versions and distributions, but some top level directories are common and very important for understanding how the kernel represents the system.
You will most often see directories such as /sys/devices, /sys/bus, /sys/class, /sys/block, and /sys/firmware. Each of these groups related kernel objects in a particular way.
Many entries inside /sys are symbolic links that connect these different views together, so that the same device can be reached from multiple paths that emphasize different aspects like hardware bus, device class, or logical representation.
`/sys/devices` and physical hardware
The /sys/devices directory represents hardware as the kernel discovers it. This is the closest thing to a "physical view" of your system inside /sys.
Inside /sys/devices you will find subdirectories that correspond to buses and controllers, for example pci0000:00 for PCI devices or platform for built in devices. If you navigate through these directories, you eventually reach paths that represent specific pieces of hardware, such as a network card or a USB controller.
Each hardware device directory contains files and subdirectories that describe attributes like vendor, device IDs, power management information, and sometimes operational parameters. For example, a device might have files like vendor, device, or power/control.
`/sys/class` and device classes
While /sys/devices follows physical relationships, /sys/class groups devices by function or "class". Classes represent categories like network interfaces, input devices, or storage.
For example, network interfaces such as eth0 or wlan0 usually appear under /sys/class/net. Storage related entries like sda appear under /sys/class/block. Each directory under /sys/class is a class, and the entries within are symbolic links to the actual device directories under /sys/devices.
This functional grouping is helpful when you care about what a device does rather than exactly where it is attached. When tools or scripts need to find all network interfaces or all block devices, /sys/class provides a convenient way to do that.
`/sys/bus` and hardware buses
The /sys/bus directory organizes devices according to the bus type that connects them. Common bus types include PCI, USB, and platform buses.
Each bus under /sys/bus typically contains subdirectories like devices and drivers. The devices directory shows which devices are currently attached to that bus, and drivers lists the kernel drivers that can handle those devices.
The entries in /sys/bus are a way to see the connection between particular hardware buses and the drivers that manage them. This is especially useful for understanding which driver a device is using, or for advanced tasks like binding or unbinding a driver from a device through the files provided there.
`/sys/block` and block devices
The /sys/block directory presents block devices, such as hard disks, SSDs, and some other storage like loop devices. Each block device appears here by name, for example sda or nvme0n1.
Inside each block device directory you will find information such as the size of the device, some statistics about I/O operations, and links to partitions. The block device entries are also tied back into /sys/devices and /sys/class, so the kernel exposes the same underlying object through multiple views.
This representation is important to tools that manage storage, because it gives a structured and consistent way to inspect the kernel's view of disks and their properties.
`/sys/firmware` and system firmware interfaces
The /sys/firmware directory exposes information and interfaces related to system firmware. Depending on the platform and firmware features, you may see directories here such as efi or acpi.
On systems that boot using UEFI, /sys/firmware/efi often contains runtime variables and interfaces related to the firmware. On systems that use ACPI, /sys/firmware/acpi can provide access to ACPI tables and controls. These details matter mainly for debugging platform level behavior or for specialized system tools.
Attribute files and kernel parameters under `/sys`
Inside device directories and subsystem directories in /sys, you often find simple text files that represent kernel attributes. Many of these can be read to obtain status or configuration, such as current power state, queue sizes, or various limits.
Some of these files are read only and exist purely to report information. Others are writable and allow the administrator to adjust behavior at runtime. A typical pattern to change a setting is to echo a new value into a file, for example:
echo performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governorThis style of access uses the normal file abstraction to configure kernel subsystems. It is more direct and immediate than using configuration files on disk, and it affects the running system without requiring a reboot.
Writing incorrect values to writable files in /sys can cause instability, performance problems, or hardware misbehavior. Only change these values when you understand their purpose and valid ranges.
Relationship between `/sys` and user space tools
Many user space tools that query hardware or system status internally read information from /sys. For example, tools that report CPU frequency, device trees, or power management status usually rely on the data the kernel exports through sysfs.
This means that /sys is a foundational interface between the kernel and higher level utilities. When you inspect /sys directly, you are often seeing the same information that graphical tools or command line utilities present in a more user friendly format.
Because /sys reflects the live state of the kernel, it is a key part of how Linux systems achieve flexibility in hardware management and configuration without editing static files for every change.