Sysctl

From Gentoo Wiki
Jump to:navigation Jump to:search

sysctl is provided by sys-process/procps, and can be used to configure kernel parameters at system runtime.

Introduction

sysctl can be used to manage the system's kernel configuration, available through /proc/sys/.

Note
sysctl parameter names can be found using file paths under /proc/sys/, replacing the "/" with ".".

Installation

Kernel

KERNEL Enable procfs support
File systems  --->
   Pseudo filesystems  --->
      <*>  /proc file system support

Emerge

root #emerge --ask sys-process/procps
Note
This package is typically installed by default.

Configuration

Kernel parameters can be configured by editing .conf files under /etc/sysctl.d.

Note
Multiple files can be used, but they will be processed in lexicographical order, and values defined multiple times will take the last value. /etc/sysctl.conf is typically loaded last.

Service

OpenRC

The OpenRC sysctl init script is enabled by default, it simply executes sysctl --system.

Systemd

The Systemd systemd-sysctl service is enabled by default.

Usage

Viewing current values

Current kernel configuration values can be printed with:

root #sysctl --all

Setting values

Values can be updated using:

root #sysctl --write {parameter}={value}
Important
Setting values this way does not persist across reboots.

Reloading values

Configuration values can be reloaded as they would be read on boot with:

root #sysctl --system

Filtering values

--pattern can be used to filter to parameters which match the supplied extended regex. This can be used for both printing and setting values.

To reload all system net values:

root #sysctl --system --pattern 'net.*'