Using sysctl

The sysctl command can make viewing, setting, and automating special kernel settings very easy.

sysctl - configure kernel parameters at runtime, sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl support in Linux. You can use sysctl to both read and write sysctl data.

To get a quick overview of all settings configurable in the /proc/sys directory, type the sysctl -a command as root. This will create a large, comprehensive list, a small portion of which looks something like this:

root@dell:~# sysctl -a
kernel.sched_min_granularity_ns = 4000000
kernel.sched_latency_ns = 20000000
kernel.sched_wakeup_granularity_ns = 5000000
kernel.sched_shares_ratelimit = 250000
kernel.sched_child_runs_first = 1
kernel.sched_features = 7935

You can manually assign values to writable files by echoing the value to the file.

The sysctl command is able to do the same thing by typing the sysctl -w [file]=”[new-value]“ command. For example, to activate the System Request Key, the following command is required:

root@dell# sysctl -w kernel.sysrq=”1″
kernel.sysrq = 1

To preserve the settings that you like to make permanently to your kernel, add them to the /etc/sysctl.conf file.

Any values added to /etc/sysctl.conf will take effect right after the system boots with no need to reconfigure and rebuild the kernel to incorporate the change.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.