From Gentoo Wiki
Jump to:navigation Jump to:search
Other languages:

Warning: Display title "sysfs/en" overrides earlier display title "Sysfs".

sysfs is a virtual filesystem (virtual means it takes up no disk space). It exports information about devices and drivers and is also used for configuration. It's 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.