---
name: "sysctl"
section: "8"
platform: "macos"
package: "system_cmds"
version: "1042.120.1"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/sysctl"
---

# sysctl(8)

get or set kernel state

## NAME

**sysctl** – get or set kernel state

## SYNOPSIS

**sysctl** \[**-bdeFhilNnotqWx**\] \[**-B** *bufsize*\] \[**-f** *filename*\] *name*\[=*value*\[,*value*\]\] *...*

**sysctl** \[**-bdeFhlNnotqWx**\] \[**-B** *bufsize*\] **-a**

## DESCRIPTION

The **sysctl** 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, described as a dotted set of components.

The following options are available:

- **-A**

  Equivalent to **-o** **-a** (for compatibility).

- **-a**

  List all the currently available values except for those which are opaque or excluded from listing via the CTLFLAG\_SKIP flag. This option is ignored if one or more variable names are specified on the command line.

- **-b**

  Force the value of the variable(s) to be output in raw, binary format. No names are printed and no terminating newlines are output. This is mostly useful with a single variable.

- **-B** *bufsize*

  Set the buffer size to read from the **sysctl** to *bufsize*. This is necessary for a **sysctl** that has variable length, and the probe value of 0 is a valid length.

- **-d**

  Print the description of the variable instead of its value.

- **-e**

  Separate the name and the value of the variable(s) with ‘=’. This is useful for producing output which can be fed back to the **sysctl** utility. This option is ignored if either **-N** or **-n** is specified, or a variable is being set.

- **-f** *filename*

  Specify a file which contains a pair of name and value in each line. **sysctl** reads and processes the specified file first and then processes the name and value pairs in the command line argument.

- **-F**

  Print the format of the variable. This is additional information to describe the type of the variable and most useful with struct types such as clockinfo, timeval, and loadavg.

- **-h**

  Format output for human, rather than machine, readability.

- **-i**

  Ignore unknown OIDs. The purpose is to make use of **sysctl** for collecting data from a variety of machines (not all of which are necessarily running exactly the same software) easier.

- **-l**

  Show the length of variables along with their values. This option cannot be combined with the **-N** option.

- **-N**

  Show only variable names, not their values. This is particularly useful with shells that offer programmable completion. To enable completion of variable names in [zsh(1)](/zsh/1.md) (*ports/shells/zsh*), use the following code:

  ```
  listsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
  compctl -K listsysctls sysctl
  ```

  To enable completion of variable names in [tcsh(1)](/tcsh/1.md), use:

  ```
  complete sysctl 'n/*/`sysctl -Na`/'
  ```

- **-n**

  Do not show variable names. This option is useful for setting shell variables. For instance, to save the pagesize in variable *psize*, use:

  ```
  set psize=`sysctl -n hw.pagesize`
  ```

- **-o**

  Show opaque variables (which are normally suppressed). The format and length are printed, as well as a hex dump of the first sixteen bytes of the value.

- **-q**

  Suppress some warnings generated by **sysctl** to standard error.

- **-t**

  Print the type of the variable.

- **-W**

  Display only writable variables. Useful for determining the set of runtime tunable sysctls.

- **-X**

  Equivalent to **-x** **-a** (for compatibility).

- **-x**

  As **-o**, but prints a hex dump of the entire value instead of just the first few bytes.

The information available from **sysctl** consists of integers, strings, and opaque types. The **sysctl** utility only knows about a couple of opaque types, and will resort to hexdumps for the rest. The opaque information is much more useful if retrieved by special purpose programs such as [ps(1)](/ps/1.md), [systat(1)](/systat/1.md), and [netstat(1)](/netstat/1.md).

The string and integer information is summarized below. For a detailed description of these variables see [sysctl(3)](/sysctl/3.md).

The changeable column indicates whether a process with appropriate privilege can change the value. String and integer values can be set using **sysctl**.

| | | |
| --- | --- | --- |
| **Name** | Type | Changeable |
| hw.activecpu | integer | no |
| hw.busfrequency | integer | no |
| hw.busfrequency\_max | integer | no |
| hw.busfrequency\_min | integer | no |
| hw.byteorder | integer | no |
| hw.cacheconfig | struct | no |
| hw.cachelinesize | integer | no |
| hw.cachesize | struct | no |
| hw.cpu64bit\_capable | integer | no |
| hw.cpufamily | integer | no |
| hw.cpufrequency | integer | no |
| hw.cpufrequency\_max | integer | no |
| hw.cpufrequency\_min | integer | no |
| hw.cpusubtype | integer | no |
| hw.cputhreadtype | integer | no |
| hw.cputype | integer | no |
| hw.l1dcachesize | integer | no |
| hw.l1icachesize | integer | no |
| hw.l2cachesize | integer | no |
| hw.l3cachesize | integer | no |
| hw.logicalcpu | integer | no |
| hw.logicalcpu\_max | integer | no |
| hw.memsize | integer | no |
| hw.ncpu | integer | no |
| hw.packages | integer | no |
| hw.pagesize | integer | no |
| hw.physicalcpu | integer | no |
| hw.physicalcpu\_max | integer | no |
| hw.tbfrequency | integer | no |
| kern.argmax | integer | no |
| kern.bootargs | string | no |
| kern.boottime | struct | no |
| kern.clockrate | struct | no |
| kern.coredump | integer | yes |
| kern.corefile | string | yes |
| kern.flush\_cache\_on\_write | integer | yes |
| kern.hostid | integer | yes |
| kern.hostname | string | yes |
| kern.job\_control | integer | no |
| kern.maxfiles | integer | yes |
| kern.maxfilesperproc | integer | yes |
| kern.maxnbuf | integer | yes |
| kern.maxproc | integer | yes |
| kern.maxprocperuid | integer | yes |
| kern.maxvnodes | integer | yes |
| kern.msgbuf | integer | yes |
| kern.nbuf | integer | no |
| kern.netboot | integer | no |
| kern.ngroups | integer | no |
| kern.nisdomainname | string | yes |
| kern.num\_files | integer | no |
| kern.num\_tasks | integer | no |
| kern.num\_taskthreads | integer | no |
| kern.num\_threads | integer | no |
| kern.num\_vnodes | integer | no |
| kern.nx | integer | yes |
| kern.osrelease | string | no |
| kern.osrevision | integer | no |
| kern.ostype | string | no |
| kern.osversion | string | yes |
| kern.posix1version | integer | no |
| kern.procname | string | yes |
| kern.safeboot | integer | no |
| kern.saved\_ids | integer | no |
| kern.secure\_kernel | integer | no |
| kern.securelevel | integer | yes |
| kern.singleuser | integer | no |
| kern.sleeptime | struct | no |
| kern.slide | integer | no |
| kern.stack\_depth\_max | integer | no |
| kern.stack\_size | integer | no |
| kern.sugid\_coredump | integer | yes |
| kern.sugid\_scripts | integer | yes |
| kern.symfile | string | no |
| kern.usrstack | integer | no |
| kern.usrstack64 | integer | no |
| kern.uuid | string | no |
| kern.version | string | no |
| kern.waketime | struct | no |
| machdep.cpu.address\_bits.physical | integer | no |
| machdep.cpu.address\_bits.virtual | integer | no |
| machdep.cpu.brand | integer | no |
| machdep.cpu.brand\_string | string | no |
| machdep.cpu.cache.L2\_associativity | integer | no |
| machdep.cpu.cache.linesize | integer | no |
| machdep.cpu.cache.size | integer | no |
| machdep.cpu.core\_count | integer | no |
| machdep.cpu.cores\_per\_package | integer | no |
| machdep.cpu.extfamily | integer | no |
| machdep.cpu.extfeature\_bits | integer | no |
| machdep.cpu.extfeatures | string | no |
| machdep.cpu.extmodel | integer | no |
| machdep.cpu.family | integer | no |
| machdep.cpu.feature\_bits | integer | no |
| machdep.cpu.features | string | no |
| machdep.cpu.leaf7\_feature\_bits | integer | no |
| machdep.cpu.leaf7\_features | string | no |
| machdep.cpu.logical\_per\_package | integer | no |
| machdep.cpu.max\_basic | integer | no |
| machdep.cpu.max\_ext | integer | no |
| machdep.cpu.microcode\_version | integer | no |
| machdep.cpu.model | integer | no |
| machdep.cpu.processor\_flag | integer | no |
| machdep.cpu.signature | integer | no |
| machdep.cpu.stepping | integer | no |
| machdep.cpu.thread\_count | integer | no |
| machdep.cpu.tlb.data.large | integer | no |
| machdep.cpu.tlb.data.large\_level1 | integer | no |
| machdep.cpu.tlb.data.small | integer | no |
| machdep.cpu.tlb.data.small\_level1 | integer | no |
| machdep.cpu.tlb.inst.large | integer | no |
| machdep.cpu.tlb.inst.small | integer | no |
| machdep.cpu.tlb.shared | integer | no |
| machdep.cpu.ucupdate | integer | yes |
| machdep.cpu.vendor | string | no |
| machdep.cpu.xsave.extended\_state | integer | no |
| machdep.tsc.deep\_idle\_rebase | integer | yes |
| machdep.tsc.frequency | integer | no |
| machdep.tsc.nanotime.generation | integer | no |
| machdep.tsc.nanotime.shift | integer | no |
| net.inet.ip.forwarding | integer | yes |
| net.inet.ip.portrange.first | integer | yes |
| net.inet.ip.portrange.hifirst | integer | yes |
| net.inet.ip.portrange.hilast | integer | yes |
| net.inet.ip.portrange.last | integer | yes |
| net.inet.ip.portrange.lowfirst | integer | yes |
| net.inet.ip.portrange.lowlast | integer | yes |
| net.inet.ip.redirect | integer | yes |
| net.inet.ip.ttl | integer | yes |
| net.inet.udp.checksum | integer | yes |
| net.inet.udp.maxdgram | integer | yes |
| vm.loadavg | struct | no |
| vm.swapusage | struct | no |
| user.bc\_base\_max | integer | no |
| user.bc\_dim\_max | integer | no |
| user.bc\_scale\_max | integer | no |
| user.bc\_string\_max | integer | no |
| user.coll\_weights\_max | integer | no |
| user.cs\_path | string | no |
| user.expr\_nest\_max | integer | no |
| user.line\_max | integer | no |
| user.posix2\_c\_bind | integer | no |
| user.posix2\_c\_dev | integer | no |
| user.posix2\_char\_term | integer | no |
| user.posix2\_fort\_dev | integer | no |
| user.posix2\_fort\_run | integer | no |
| user.posix2\_localedef | integer | no |
| user.posix2\_sw\_dev | integer | no |
| user.posix2\_upe | integer | no |
| user.posix2\_version | integer | no |
| user.re\_dup\_max | integer | no |
| user.stream\_max | integer | no |
| user.tzname\_max | integer | no |

Note that the *hw.ncpu* attribute is deprecated, and one of the more specific MIBs, *hw.logicalcpu*, *hw.logicalcpu\_max*, *hw.physicalcpu*, or *hw.physicalcpu\_max*, should be used instead.

## FILES

- In sys/sysctl.h

  definitions for top level identifiers, second level kernel and hardware identifiers, and user level identifiers

- In sys/socket.h

  definitions for second level network identifiers

- In sys/gmon.h

  definitions for third level profiling identifiers

- In vm/vm\_param.h

  definitions for second level virtual memory identifiers

- In netinet/in.h

  definitions for third level Internet identifiers and fourth level IP identifiers

- In netinet/icmp\_var.h

  definitions for fourth level ICMP identifiers

- In netinet/udp\_var.h

  definitions for fourth level UDP identifiers

## EXIT STATUS

The **sysctl** utility exits 0 on success, and \>0 if an error occurs.

## EXAMPLES

For example, to retrieve the maximum number of processes allowed in the system, one would use the following request:

```
sysctl kern.maxproc
```

To set the maximum number of processes allowed per uid to 1000, one would use the following request:

```
sysctl kern.maxprocperuid=1000
```

Information about the system clock rate may be obtained with:

```
sysctl kern.clockrate
```

Information about the load average history may be obtained with:

```
sysctl vm.loadavg
```

More variables than these exist, and the best and likely only place to search for their deeper meaning is undoubtedly the source where they are defined.

## COMPATIBILITY

The **-w** option has been deprecated and is silently ignored.

## SEE ALSO

[sysctl(3)](/sysctl/3.md), [sysctl.conf(5)](/sysctl.conf/5.md)

## HISTORY

A **sysctl** utility first appeared in 4.4BSD.

In FreeBSD 2.2, **sysctl** was significantly remodeled.
