Skip to main content

LFCS Certification Course

Chapter #15: Manage Kernel Runtime Parameters in Linux

In this article, we explain how to view and modify Linux kernel runtime parameters using sysctl, /proc/sys, and configuration files.

In Chapter 13 (β€œGRUB and the boot process”), we explained how to use GRUB to modify the behavior of the system by passing options to the kernel during the boot process.

Similarly, you can use the command line in a running Linux system to alter certain runtime kernel parameters as a one-time modification or permanently by editing a configuration file.

Thus, you can enable or disable kernel parameters on the fly without much difficulty when a required change in the way the system is expected to operate arises.

Introducing the /proc Filesystem

The latest specification of the Filesystem Hierarchy Standard indicates that /proc represents the default method for handling process and system information, as well as other kernel and memory information.

Particularly, /proc/sys is where you can find all the information about devices, drivers, and some kernel features.

The actual internal structure of /proc/sys depends heavily on the kernel being used, but you are likely to find the following directories inside.

In turn, each of them will contain other subdirectories where the values for each parameter category are maintained:

  • dev: parameters for specific devices connected to the machine.
  • fs: filesystem configuration (quotas and inodes, for example).
  • kernel: kernel-specific configuration.
  • net: network configuration.
  • vm: use of the kernel’s virtual memory.

Viewing and Modifying Kernel Parameters

To modify the kernel runtime parameters, we will use the sysctl command. The exact number of parameters that can be modified can be viewed with:

sysctl -a | wc -l

If you want to view the complete list of parameters, just do:

sysctl -a

As the output of the above command will consist of a lot of lines, we can use a pipeline followed by less to inspect it more carefully:

sysctl -a | less

Let’s take a look at the first few lines. Please note that the first characters in each line match the names of the directories inside /proc/sys:

Understanding Linux sysctl Output

For example, the highlighted line: