CINXE.COM
sysctl(8) - OpenBSD manual pages
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="/mandoc.css" type="text/css" media="all"> <title>sysctl(8) - OpenBSD manual pages</title> </head> <body> <header> <section> <h1><a href="https://www.openbsd.org/">OpenBSD</a> manual page server</h1> </section> <form role="search" action="/" method="get" autocomplete="off" autocapitalize="none"> <fieldset> <legend>Manual Page Search Parameters</legend> <label>Search query: <input type="search" name="query" value="sysctl" size="40"> </label> <button type="submit" name="apropos" value="0">man</button> <button type="submit" name="apropos" value="1">apropos</button> <br/> <select name="sec" aria-label="Manual section"> <option value="0">All Sections</option> <option value="1">1 - General Commands</option> <option value="2">2 - System Calls</option> <option value="3">3 - Library Functions</option> <option value="3p">3p - Perl Library</option> <option value="4">4 - Device Drivers</option> <option value="5">5 - File Formats</option> <option value="6">6 - Games</option> <option value="7">7 - Miscellaneous Information</option> <option value="8" selected="selected">8 - System Manager's Manual</option> <option value="9">9 - Kernel Developer's Manual</option> </select> <select name="arch" aria-label="CPU architecture"> <option value="default" selected="selected">All Architectures</option> <option>amd64</option> <option>alpha</option> <option>armv7</option> <option>arm64</option> <option>hppa</option> <option>i386</option> <option>landisk</option> <option>loongson</option> <option>luna88k</option> <option>macppc</option> <option>mips64</option> <option>octeon</option> <option>powerpc64</option> <option>riscv64</option> <option>sparc64</option> <option>amiga</option> <option>arc</option> <option>armish</option> <option>arm32</option> <option>atari</option> <option>aviion</option> <option>beagle</option> <option>cats</option> <option>hppa64</option> <option>hp300</option> <option>ia64</option> <option>mac68k</option> <option>mvme68k</option> <option>mvme88k</option> <option>mvmeppc</option> <option>palm</option> <option>pc532</option> <option>pegasos</option> <option>pmax</option> <option>powerpc</option> <option>sgi</option> <option>socppc</option> <option>solbourne</option> <option>sparc</option> <option>sun3</option> <option>vax</option> <option>wgrisc</option> <option>x68k</option> <option>zaurus</option> </select> <select name="manpath" aria-label="Manual path"> <option selected="selected">OpenBSD-current</option> <option>OpenBSD-7.6</option> <option>OpenBSD-7.5</option> <option>OpenBSD-7.4</option> <option>OpenBSD-7.3</option> <option>OpenBSD-7.2</option> <option>OpenBSD-7.1</option> <option>OpenBSD-7.0</option> <option>OpenBSD-6.9</option> <option>OpenBSD-6.8</option> <option>OpenBSD-6.7</option> <option>OpenBSD-6.6</option> <option>OpenBSD-6.5</option> <option>OpenBSD-6.4</option> <option>OpenBSD-6.3</option> <option>OpenBSD-6.2</option> <option>OpenBSD-6.1</option> <option>OpenBSD-6.0</option> <option>OpenBSD-5.9</option> <option>OpenBSD-5.8</option> <option>OpenBSD-5.7</option> <option>OpenBSD-5.6</option> <option>OpenBSD-5.5</option> <option>OpenBSD-5.4</option> <option>OpenBSD-5.3</option> <option>OpenBSD-5.2</option> <option>OpenBSD-5.1</option> <option>OpenBSD-5.0</option> <option>OpenBSD-4.9</option> <option>OpenBSD-4.8</option> <option>OpenBSD-4.7</option> <option>OpenBSD-4.6</option> <option>OpenBSD-4.5</option> <option>OpenBSD-4.4</option> <option>OpenBSD-4.3</option> <option>OpenBSD-4.2</option> <option>OpenBSD-4.1</option> <option>OpenBSD-4.0</option> <option>OpenBSD-3.9</option> <option>OpenBSD-3.8</option> <option>OpenBSD-3.7</option> <option>OpenBSD-3.6</option> <option>OpenBSD-3.5</option> <option>OpenBSD-3.4</option> <option>OpenBSD-3.3</option> <option>OpenBSD-3.2</option> <option>OpenBSD-3.1</option> <option>OpenBSD-3.0</option> <option>OpenBSD-2.9</option> <option>OpenBSD-2.8</option> <option>OpenBSD-2.7</option> <option>OpenBSD-2.6</option> <option>OpenBSD-2.5</option> <option>OpenBSD-2.4</option> <option>OpenBSD-2.3</option> <option>OpenBSD-2.2</option> </select> </fieldset> </form> </header> <hr> <div class="head" role="doc-pageheader" aria-label="Manual header line"><span class="head-ltitle">SYSCTL(8)</span> <span class="head-vol">System Manager's Manual</span> <span class="head-rtitle">SYSCTL(8)</span></div> <main class="manual-text"> <section class="Sh"> <h2 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h2> <p class="Pp"><code class="Nm">sysctl</code> — <span class="Nd" role="doc-subtitle">get or set kernel state</span></p> </section> <section class="Sh"> <h2 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h2> <table class="Nm"> <tr> <td><code class="Nm">sysctl</code></td> <td>[<code class="Fl">-Aanq</code>] [<var class="Ar">name</var>[=<var class="Ar">value</var>] <var class="Ar">...</var>]</td> </tr> </table> </section> <section class="Sh"> <h2 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h2> <p class="Pp">The <code class="Nm">sysctl</code> utility retrieves kernel state and allows processes with appropriate privilege to set kernel state. The state to be retrieved or set is described using a “Management Information Base” (MIB) style name, using a dotted set of components.</p> <p class="Pp">When retrieving a variable, a subset of the MIB name may be specified to retrieve a list of variables in that subset. For example, to list all the machdep variables:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">$ sysctl machdep</code></div> <p class="Pp">The options are as follows:</p> <dl class="Bl-tag"> <dt id="A"><a class="permalink" href="#A"><code class="Fl">-A</code></a></dt> <dd>List all the known MIB names including tables. Those with string or integer values will be printed as with the <code class="Fl">-a</code> flag; for the table values, the name of the utility to retrieve them is given.</dd> <dt id="a"><a class="permalink" href="#a"><code class="Fl">-a</code></a></dt> <dd>List all the currently available string or integer values. This is the default, if no parameters are given to <code class="Nm">sysctl</code>.</dd> <dt id="n"><a class="permalink" href="#n"><code class="Fl">-n</code></a></dt> <dd>Suppress printing of the field name, only output the field value. Useful for setting shell variables. For example, to set the psize shell variable to the pagesize of the hardware: <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li"># set psize=`sysctl -n hw.pagesize`</code></div> </dd> <dt id="q"><a class="permalink" href="#q"><code class="Fl">-q</code></a></dt> <dd>Suppress all output when setting a variable. This option overrides the behaviour of <code class="Fl">-n</code>.</dd> <dt><var class="Ar">name</var>[=<var class="Ar">value</var>]</dt> <dd>Retrieve the specified variable <var class="Ar">name</var>, or attempt to set it to <var class="Ar">value</var>. Multiple <var class="Ar">name</var>[=<var class="Ar">value</var>] arguments may be given.</dd> </dl> <p class="Pp">The information available from <code class="Nm">sysctl</code> consists of integers, strings, and tables. For a detailed description of the variables, see <a class="Xr" href="/sysctl.2" aria-label="sysctl, section 2">sysctl(2)</a>. Tables can only be retrieved by special purpose programs such as <a class="Xr" href="/ps.1" aria-label="ps, section 1">ps(1)</a>, <a class="Xr" href="/systat.1" aria-label="systat, section 1">systat(1)</a>, and <a class="Xr" href="/netstat.1" aria-label="netstat, section 1">netstat(1)</a>.</p> <p class="Pp"><code class="Nm">sysctl</code> can extract information about the filesystems that have been compiled into the running system. This information can be obtained by using the command:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">$ sysctl vfs.mounts</code></div> <p class="Pp">By default, only filesystems that are actively being used are listed. Use of the <code class="Fl">-A</code> flag lists all the filesystems compiled into the running kernel.</p> </section> <section class="Sh"> <h2 class="Sh" id="FILES"><a class="permalink" href="#FILES">FILES</a></h2> <dl class="Bl-tag Bl-compact"> <dt><span class="Pa">/etc/sysctl.conf</span></dt> <dd>sysctl variables to set at system startup</dd> </dl> </section> <section class="Sh"> <h2 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h2> <p class="Pp">To retrieve the maximum number of processes allowed in the system:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">$ sysctl kern.maxproc</code></div> <p class="Pp">To set the maximum number of processes allowed in the system to 1000:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li"># sysctl kern.maxproc=1000</code></div> <p class="Pp">To retrieve information about the system clock rate:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">$ sysctl kern.clockrate</code></div> <p class="Pp">To retrieve information about the load average history:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li">$ sysctl vm.loadavg</code></div> <p class="Pp">To make the <a class="Xr" href="/chown.2" aria-label="chown, section 2">chown(2)</a> system call use traditional <span class="Ux">BSD</span> semantics (don't clear setuid/setgid bits):</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li"># sysctl fs.posix.setuid=0</code></div> <p class="Pp">To set the list of reserved TCP ports that should not be allocated by the kernel dynamically:</p> <p class="Pp"></p> <div class="Bd Bd-indent"><code class="Li"># sysctl net.inet.tcp.baddynamic=749,750,751,760,761,871</code></div> <div class="Bd Bd-indent"><code class="Li"># sysctl net.inet.udp.baddynamic=749,750,751,760,761,871,1024-2048</code></div> <p class="Pp">This can be used to keep daemons from stealing a specific port that another program needs to function. List elements may be separated by commas and/or whitespace; a hyphen may be used to specify a range of ports.</p> <p class="Pp">It is also possible to add or remove ports from the current list:</p> <div class="Bd Pp Bd-indent Li"> <pre># sysctl net.inet.tcp.baddynamic=+748,+6000-6999 # sysctl net.inet.tcp.baddynamic=-871</pre> </div> <p class="Pp">To set the amount of shared memory available in the system and the maximum number of shared memory segments:</p> <div class="Bd Pp Bd-indent Li"> <pre># sysctl kern.shminfo.shmmax=33554432 # sysctl kern.shminfo.shmseg=32</pre> </div> <p class="Pp">To place core dumps from <a class="Xr" href="/issetugid.2" aria-label="issetugid, section 2">issetugid(2)</a> programs (in this example <a class="Xr" href="/bgpd.8" aria-label="bgpd, section 8">bgpd(8)</a>) into a safe place for debugging purposes:</p> <div class="Bd Pp Bd-indent Li"> <pre># mkdir -m 700 /var/crash/bgpd # sysctl kern.nosuidcoredump=3</pre> </div> </section> <section class="Sh"> <h2 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE ALSO</a></h2> <p class="Pp"><a class="Xr" href="/sysctl.2" aria-label="sysctl, section 2">sysctl(2)</a>, <a class="Xr" href="/options.4" aria-label="options, section 4">options(4)</a>, <a class="Xr" href="/sysctl.conf.5" aria-label="sysctl.conf, section 5">sysctl.conf(5)</a></p> </section> <section class="Sh"> <h2 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h2> <p class="Pp"><code class="Nm">sysctl</code> first appeared in <span class="Ux">4.4BSD</span>.</p> </section> </main> <div class="foot" role="doc-pagefooter" aria-label="Manual footer line"><span class="foot-left"></span><span class="foot-date">September 10, 2024</span> <span class="foot-os">OpenBSD-current</span></div> </body> </html>