Home   Profile   Fun
#143 Linux  07.01.2008

Display and set Linux kernel parameters with sysctl


Provided that support for the proc pseudo filesystem is enabled in the kernel configuration (CONFIG_PROC_FS=y) and proc is mounted on /proc all available kernel parameters can be found at runtime under /proc/sys/.

To access a single parameter you can use the command cat, e.g.
cat /proc/sys/vm/min_free_kbytes

To change this parameter a new value can simply be written with echo.
echo "4096" > /proc/sys/vm/min_free_kbytes

The command sysctl lists all available kernel parameters along with their current values and paths under /proc.
sysctl -a

Changes done at runtime in /proc are lost during the next reboot. To set them permanently the file /etc/sysctl.conf can be modified accordingly. For that you must know the path to the desired parameters under /proc. The syntax for entries in /etc/sysctl.conf requires to replace the slashes in the path with dots.
Example: permanently set /proc/sys/vm/min_free_kbytes to 4096.
vm.min_free_kbytes=4096

To reload all parameters in /etc/sysctl.conf no reboot is needed. They can be loaded at runtime with the following command.
sysctl -p

A different configuration file can be loaded as well.
sysctl -p /etc/sysctl_new.conf