Mastering the Linux "sysctl" Command

Configure Kernel Parameters at Runtime

Socially anxious computer programmers may have the ideal job for regulating anxiety.
Computer programmers with social anxiety will work both with technoloogy and other people. Getty / PeopleImages.com

The Linux sysctl command configures kernel parameters at runtime. The parameters available are those listed under /proc/sys/. Procfs is required for sysctl(8) support in Linux. Use sysctl(8) to both read and write sysctl data.  

Synopsis

sysctl [-n] [-e] variable ... 
sysctl [-n] [-e] -w variable=value ... 
sysctl [-n] [-e] -p <filename> (default /etc/sysctl.conf) 
sysctl [-n] [-e] -a 
sysctl [-n] [-e] -A  

Parameters

variable

The name of a key to read from. An example is kernel.ostype. The slash separator is also accepted in place of a period delimiting the key/value pair—e.g.,  kernel/ostype.

variable=value

To set a key, use the form variable=value, where variable is the key and value is the value it's set to. If the value contains quotes or characters that are parsed by the shell, you may need to enclose the value in double quotes. This requires the -w parameter to use.

-n

Use this option to disable printing of the key name when printing values.

-e

Use this option to ignore errors about unknown keys.

-w

Use this option when you want to change a sysctl setting.

-p

Load sysctl settings from the file specified or /etc/sysctl.conf if none was given.

-a

Display all values currently available.

-A

Display all values currently available in table form.

Example Usage

/sbin/sysctl -a

/sbin/sysctl -n kernel.hostname

/sbin/sysctl -w kernel.domainname="example.com"

/sbin/sysctl -p /etc/sysctl.conf

Specific usage may vary by Linux distribution. Use the man command (% man) to see how a command is used on your particular computer.

Was this page helpful?