home | list info | list archive | date index | thread index

[OCLUG-Tech] what is the purpose of the "-w" option of "sysctl" command?

  • Subject: [OCLUG-Tech] what is the purpose of the "-w" option of "sysctl" command?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Wed, 14 Mar 2018 07:23:24 -0400 (EDT)
  just noticed something odd ... on my fedora 27 system, the man page
for sysctl reads under PARAMETERS:

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

  hang on ... setting a variable "requires" the -w parameter? that's
explained further down:

    -w, --write
       Use this option when you want to change a sysctl setting.

  as i read that, "-w" is *required* to modify a sysctl variable at
run-time, but i tested it with my favourite example:

  # sysctl net.ipv4.ip_forward=0

and that modified that variable just fine with no need for "-w":

  # sysctl net.ipv4.ip_forward
  net.ipv4.ip_forward = 0
  #

so what exactly is "-w" for?

rday