Procfs, sysfs and sysctl
Quick answer
Linux exposes selected kernel information through virtual filesystems. procfs represents process and system information; sysfs represents kernel objects and attributes; sysctl reads or changes selected runtime parameters.
Virtual files can expose values generated when read, so consecutive samples may differ even without an editor changing them. Separate observation from control: a writable kernel attribute is not an ordinary document. Use read-only inspection until a change is authorized.
Prepare the practice environment
Run python3 lab-fixtures/kernel/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not write kernel attributes, load modules, or change boot settings. Supplied records are fictional; read only the selected non-sensitive live fields. Review the lab guide.
Prerequisites
Review: Kernel modules, drivers and firmware.
How it works
Files in /proc and /sys are generated interfaces, not ordinary persistent disk files. /proc/self refers to the accessing process; PID-scoped files can contain sensitive information. /sys exposes devices, buses, classes and attributes, including symlinks between objects. Some attributes are writable and trigger changes rather than storing ordinary bytes. sysctl maps names such as kernel.osrelease to /proc/sys/kernel/osrelease. A value may be read-only, namespaced, unavailable or restricted; do not assume a container view reflects the entire host. Persistent sysctl configuration is a separate userspace policy. These examples read only selected non-sensitive fields, not broad dumps.
Try the examples
test "$(sysctl -n kernel.osrelease)" = "$(cat /proc/sys/kernel/osrelease)" && printf 'release views agree\n'Both interfaces expose the selected release value.
Expected stdout:
release views agreegrep -q '^State:' /proc/self/status && printf 'process state field present\n'Here self refers to grep, the accessing process, rather than the parent shell.
Expected stdout:
process state field presentgrep -Eq '^[0-9,-]+$' /sys/devices/system/cpu/online && printf 'CPU list present\n'The list is variable and may not equal the CPUs available to the current process.
Expected stdout:
CPU list presentCommon mistakes
Never write to /proc/sys or /sys merely to explore. Avoid collecting other processes’ environment or memory and do not assume visibility equals permission.
Practice
Compare the three read-only examples and identify which expose a process, a kernel object and a runtime parameter.
Related references
Study: sysctl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Procfs, sysfs and sysctl — Knowledge Check
Apply kernel concepts to read-only observations and synthetic models.
What does /proc/self refer to?
Which interface represents device attributes?
What does sysctl -n do when reading a key?
Are all procfs and sysfs attributes writable?