From Gentoo Wiki
Jump to:navigation Jump to:search
This page contains changes which are not marked for translation.
Other languages:
English • ‎日本語

sysfs is a virtual filesystem (virtual means it takes up no disk space). It exports information about kernel devices, drivers, and other subsystems to user space and allows their configuration. It is generated by the kernel and always mounted at /sys.


Use cat to read the information. For example, to output the charging level of a battery:

user $cat /sys/class/power_supply/BAT0/status

Get the device name by listing the /sys/class/net directory contents using ls -al or the tree command (provided by the app-text/tree package):

user $tree /sys/class/net
├── enp2s14 -> ../../devices/pci0000:00/0000:00:1e.0/0000:02:0e.0/net/enp2s14
├── lo -> ../../devices/virtual/net/lo
├── sit0 -> ../../devices/virtual/net/sit0
└── wlp8s0 -> ../../devices/pci0000:00/0000:00:1c.0/0000:08:00.0/net/wlp8s0

sysfs can be used to set values at runtime. For example, the echo command can be used to enable system suspension:

root #echo mem > /sys/power/state

To set values at boot time create a local.d script.

See also

  • tmpfs — a virtual filesystem created to store files in dynamic (volatile) memory.