procfs
| External resources |
procfs (process filesystem) is a virtual filesystem to output and change system and process information. It's generated by the kernel and mounted at /proc. The information in the sysfs filesystem replaces more and more system information of procfs.
Contents |
Installation
You need to activate the following kernel options:
File systems --->
Pseudo filesystems --->
<*> /proc file system support
Configuration
Change your fstab to mount procfs at boot time to /proc:
proc /proc proc defaults 0 0
Usage
See the Wikipedia article for the file's purpose.
- Use cat to read the information, e.g. output the version of the currently running kernel:
-
user $cat /proc/version
- To set values at runtime - if possible - use echo, e.g. to enable the magic SysRq key::
-
root #echo 1 > /proc/sys/kernel.sysrq
sysctl
| External resources |
sysctl is a mechanism to modify certain kernel parameters at runtime. It is part of procfs and the files are located at /proc/sys/. /usr/src/linux/Documentation/sysctl/ contains documentation of most files.
sysctl work with keys, which can be assembled from the file path by removing the /proc/sys prefix and replace the backsplash with a point. So, e.g. /proc/sys/kernel/sysrq becomes kernel.sysrq.
You can modify at runtime the files like above, but the tool sysctl (part of sys-process/procps) do it in a more structured way:
- To enable the magic sysrq key:
-
root #sysctl kernel.sysrq=1
- To show all keys and their current values:
-
root #sysctl -a
To configure kernel parameters at boot, add them to a .conf file in /etc/sysctl.d/. The recommended location for local settings is /etc/sysctl.d/local.conf. The legacy file /etc/sysctl.conf is also supported. To enable the magic SysRq key at boot:
kernel.sysrq=1
OpenRC
The service sysctl read the files at boot and execute the settings. The service is enabled by default.
systemd
systemd knows beside /etc/sysctl.d/ also /usr/lib/sysctl.d/ for package-provided config files.
The service systemd-sysctl is enabled by default.