LearnLinux FoundationsImportant Files and Paths

/sys

ls - a hands-on Linux lab on a real virtual machine.

Explore /sys, the virtual filesystem the kernel builds live from your hardware. The ten top-level drawers, the class grouping by device role, the net and block branches, and the one-value-per-file rule you read with cat. /sys is structure-only: your device names and values vary, so the drills teach the shape and the moves.

In the last lesson you met /proc, a folder full of files that do not exist on any disk. The kernel makes them up the instant you read them. It felt like magic. Here is the twist: /proc was only the first of two such folders.

There is a second one, and it answers a different question. /proc is mostly about what is RUNNING: processes, memory, live system stats. This second folder is about what your machine IS: the actual hardware. The network cards. The disks. The battery, if there is one. It is a clean, organized tree of every device the kernel knows about, and it is called /sys.

The black boxes in this lesson are a practice terminal: a safe sandbox that only checks the one command each step teaches, so you cannot break anything. /sys is generated live from your real hardware, so the exact names and numbers it shows change from machine to machine. Every listing here is one real capture, kept as an example. On the live machine at the end of the module, you explore your own /sys and read your own hardware.

/sys is the sysfs filesystem. Like /proc, it is virtual: the kernel builds every entry in memory the moment you look, so nothing here sits on a disk. The name is short for system filesystem.

The job of /sys is to lay out the machine's hardware and kernel objects as a tidy tree of folders and files. Think of it as a filing cabinet the kernel keeps about itself. One drawer per subject, and inside each drawer, one slip of paper per fact. That last part is the rule that makes /sys special: each file holds exactly ONE value. Not a paragraph, not a table, just a single fact like a card's speed or a disk's size.

That is the clean contrast with /proc. /proc tends to hand you free-form text: a whole status report in one file, columns and prose mixed together. /sys is stricter and more hierarchical: deep folders, and at the bottom, tiny single-value files. /proc is the messy notebook; /sys is the labelled filing cabinet.

You explore /sys the same way you explore any folder: with ls, the list command you already know. Point ls at /sys and it prints the top-level drawers, the big subsystem directories the kernel always exposes.

Run it now and read the drawer labels:

ls /sys

prompt: student@linuxcamp:~$ answer: ls /sys output: block bus class dev devices firmware fs kernel module power hint: Type ls, a space, then the path: ls /sys

Those ten names are the standard top-level drawers of /sys, and they are the same on essentially every Linux machine. A few worth knowing by name: block holds your disks, class groups devices by what they DO (network, power, sound), devices is the full raw device tree, and power holds system power settings. You will not memorize all ten today. The point is the shape: /sys opens into a small, predictable set of subsystem folders, and from there you drill down.

The drawer NAMES above are stable everywhere. What lives INSIDE them is your machine's own hardware and will differ from this capture. A cloud server, a laptop, and a Raspberry Pi all show these same ten folders at the top, then diverge completely once you look inside. That top-level shape is the part worth memorizing.

Of those ten, the one you will open most is class. It groups every device by its ROLE, so you do not have to know where a device physically lives to find it. Want anything network-related? Look in the net class. Want battery info? Look in the power_supply class.

The branch that pays off first is /sys/class/net, the list of network interfaces on the machine. Each entry is one network connection point the kernel can see. List it:

ls /sys/class/net

prompt: student@linuxcamp:~$ answer: ls /sys/class/net output: eth0 lo hint: Same ls, drilling one level deeper: ls /sys/class/net

Those names are this machine's. lo you will see everywhere: it is the loopback interface, the machine's way of talking to itself, and it is always present. The other name varies a lot. This capture shows eth0, but modern systems often name the real card ens3, enp0s3, or eno1 instead. Do not memorize the name; memorize the MOVE: ls /sys/class/net lists whatever interfaces THIS machine has.

Here is where the one-value-per-file rule pays off. Each interface in /sys/class/net is itself a folder, and inside it are little single-fact files. Open eth0 and one of the files is address: it holds that card's MAC address, the unique hardware ID burned into every network interface, and nothing else.

You do not ls a single-value file, you READ it, and the tool for reading a file's contents is cat, which you met earlier in the course. Point cat at the leaf file:

cat /sys/class/net/eth0/address

prompt: student@linuxcamp:~$ answer: cat /sys/class/net/eth0/address output: 02:42:ac:11:00:02 hint: Use cat to read the single-value file: cat /sys/class/net/eth0/address

That MAC address is unique to the card this was captured from; yours will be a different string of six colon-separated pairs. And if your machine named its interface ens3 instead of eth0, the path changes to match: cat /sys/class/net/ens3/address. The lesson is the pattern, not the value: drill down through class, into a device folder, and cat a single-value file to read exactly one fact.

Networking is not the only thing /sys catalogs. The block drawer at the top level lists your block devices, which is the proper name for disks: the drives that store data in fixed-size blocks. List it:

ls /sys/block

prompt: student@linuxcamp:~$ answer: ls /sys/block output: sda hint: Point ls at the block drawer: ls /sys/block

Disk names are hardware-specific. Older or virtualized machines call the first disk sda; a machine with a modern NVMe solid-state drive calls it nvme0n1 instead. Some machines list several disks, some just one. Whatever the name, the same trick applies: each disk is a folder, and inside it are single-value files. For instance cat /sys/block/sda/size prints the disk size measured in 512-byte sectors, one number, nothing else. Your disk name and that number will both differ.

One more branch worth knowing for later: /sys/class/power_supply. On a laptop it holds battery folders, and files inside report the charge level and whether the machine is plugged in. On a desktop or a cloud server with no battery, that folder is simply empty. That is normal, not a fault: /sys only shows hardware that actually exists.

Scaffolding off. No command is printed this time. You have every piece you need.

You have landed on an unfamiliar machine and you want to know one thing: what network interfaces does it have? You remember that /sys groups devices by role under class, and that networking lives in the net group. List that folder so the machine tells you its interfaces.

prompt: student@linuxcamp:~$ answer: ls /sys/class/net output: eth0 lo hint: Use ls on the path that groups devices by role, then the net group. Think ls, then /sys/class/net.

That is the everyday move. ls explored the tree, and the path /sys/class/net pinned it to network devices, so the machine listed its own interfaces. Your machine will almost certainly show lo plus at least one more, and that other name may not be eth0. But the shape holds: drill through class to the role you care about, then ls it. That is exactly what a working engineer does to see hardware without any special tool. You recalled the path from memory, which is the same recall the real machine will ask of you.

You earned this cheat sheet. Every row is a move you just made:

And the mental model you can now carry to any Linux box: /sys is a virtual tree the kernel builds live from your hardware. You ls your way DOWN through subsystem folders, and at the bottom you cat a single-value file to read one exact fact.

One safety note for the road. Some files in /sys are not just readable, they are WRITABLE. Writing to one changes a live kernel or device setting on the spot. That is a real and powerful tool, but it is advanced, and doing it by accident can misconfigure hardware. While you are learning, treat /sys as a place you READ with ls and cat. It is a window onto the machine, not a folder where you save your own files.

The practice terminal has shown you the shape of /sys. You have the ten top-level drawers, the class grouping by device role, the network and block branches, and the one-value-per-file rule that lets you cat a single fact. Every one of those you typed yourself.

The Important Files module ends with one real Linux machine, the Important Files capstone mission, and that is where you explore /sys for real. A VM boots just for you, with its own live hardware. It hands you objectives that use exactly what you practiced across this module: reading the account and hostname files, the release and mount files, and now walking the kernel's own view of the machine in /proc and /sys. One difference from here: the mission shows no commands. You read the objective, you recall the command, you type it. That recall is what makes it stick.

Finish the other Important Files lessons, then go read a real machine's hardware for yourself.

Practice /sys in a real Linux terminal at The Linux Camp. Progress is verified automatically as you type commands on the machine.