Linux Virtual Filesystems: /proc, /sys and /dev
What you need to know
Some Linux paths look like files but provide interfaces to the running kernel or devices. They need not be ordinary documents saved on a disk. Reading or writing an interface can have different effects from reading or writing a regular file. In this lesson use only the selected harmless reads.
How the layout works
/proc normally exposes process and kernel information through procfs. Some entries are generated when read, and some settings are writable. Numeric directory names can identify processes; access is restricted by permissions and namespace boundaries. /sys normally exposes kernel objects such as devices and drivers through sysfs; it also contains attributes that can control behavior. /dev contains special device entries (character and block devices) and other interfaces; the directory may be backed by devtmpfs, tmpfs or another setup. /dev/null is a special character device that produces end-of-file when read and discards data written to it.
A pseudo-filesystem is a filesystem-like interface to information or services rather than necessarily a collection of stored disk files. A container may expose only part of these interfaces.
Before practicing
Use a normal user in your disposable Linux lab with Bash, GNU Coreutils and util-linux. These examples inspect specific paths only; no sudo is needed. If a directory, command or permission is missing, record the difference and stop rather than changing the system. Ubuntu 24.04 LTS is the teaching baseline; the recorded local outputs are from Debian 13.3 in a container.
Read a small kernel attribute
On an ordinary Linux system with this interface available, prints Linux. It is kernel information, not the distribution name. Do not write to /proc/sys.
Identify virtual filesystem types
findmnt -n -o TARGET,FSTYPE --target /procfindmnt -n -o TARGET,FSTYPE --target /sysTypically /proc proc and /sys sysfs are shown (column spacing varies). If a restricted environment lacks these mounts, results may differ.
Read a device with no data
On a normal Linux device setup, prints a byte count of zero and the path. This is not a general rule for reading devices. Never read arbitrary device files: some block, produce unlimited data or expose sensitive information.
A count of zero means that the read returned no data before reaching end-of-file. It does not mean that a byte with numeric value zero was returned. This distinction helps when interpreting byte counts from special interfaces; do not extrapolate it to other devices.
Common mistakes
Do not recursively read /proc, /sys or /dev, change attributes, or treat device files as ordinary text. Some interfaces can disclose credentials or control hardware; stay with the small named examples. File size reported by stat is not a reliable prediction of generated virtual-file content.
Try it yourself
Match process information, a device attribute and a data-discarding interface to /proc, /sys and /dev/null. Explain why copying all of /proc is not a normal backup task.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Virtual filesystems and devices — Knowledge Check
Apply Linux filesystem layout concepts and interpret safe inspection results.
Which interface commonly presents process information?
What does `cat /proc/sys/kernel/ostype` identify on a normal Linux system?
What normally happens when you read `/dev/null`?
Which path normally exposes device and driver attributes through sysfs?
Why avoid recursively reading /dev or /proc?