manpagez: man pages & more
man sysctl(8)
Home | html | info | man
sysctl(8)                 BSD System Manager's Manual                sysctl(8)


     sysctl -- get or set kernel state


     sysctl [-bn] name ...
     sysctl [-bn] -w name=value ...
     sysctl [-bn] -a
     sysctl [-bn] -A
     sysctl [-bn] -X


     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      List all MIB variables including opaque variables (which are nor-
             mally suppressed).  The format and length are printed, as well as
             a hex dump of the first sixteen bytes of the value.

     -a      List all the currently available non-opaque values.  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.

     -n      Show only variable values, not their names.  This option is use-
             ful for setting shell variables.  For instance, to save the page-
             size in variable psize, use:

                   set psize=`sysctl -n hw.pagesize`

     -w name=value
             Used to set values.  The MIB name ( name ) followed by an equal
             sign and the new value ( value ) to be used.

     -X      Same as -A, but prints a hex dump of the entire value instead of
             just the first few bytes.

     If just a MIB style name is given, the corresponding value is retrieved.

     The information available from sysctl consists of integers, strings, and
     tables.  The tabular information can only be retrieved by special purpose
     programs such as ps, systat, and netstat.  The string and integer infor-
     mation is summarized below.  For a detailed description of these variable
     see sysctl(3).  The changeable column indicates whether a process with
     appropriate privilege can change the value.

     Name                            Type          Changeable
     kern.ostype                     string        no
     kern.osrelease                  string        no
     kern.osrevision                 integer       no
     kern.version                    string        no
     kern.maxvnodes                  integer       yes
     kern.maxproc                    integer       yes
     kern.maxfiles                   integer       yes
     kern.argmax                     integer       no
     kern.securelevel                integer       raise only
     kern.hostname                   string        yes
     kern.hostid                     integer       yes
     kern.clockrate                  struct        no
     kern.posix1version              integer       no
     kern.ngroups                    integer       no
     kern.job_control                integer       no
     kern.saved_ids                  integer       no
     kern.link_max                   integer       no
     kern.max_canon                  integer       no
     kern.max_input                  integer       no
     kern.name_max                   integer       no
     kern.path_max                   integer       no
     kern.pipe_buf                   integer       no
     kern.chown_restricted           integer       no
     kern.no_trunc                   integer       no
     kern.vdisable                   integer       no
     kern.boottime                   struct        no
     vm.loadavg                      struct        no
     vm.swapusage                    struct        no
     machdep.console_device          dev_t         no
     net.inet.ip.forwarding          integer       yes
     net.inet.ip.redirect            integer       yes
     net.inet.ip.ttl                 integer       yes
     net.inet.icmp.maskrepl          integer       yes
     net.inet.udp.checksum           integer       yes
     hw.machine                      string        no
     hw.model                        string        no
     hw.ncpu                         integer       no
     hw.byteorder                    integer       no
     hw.physmem                      integer       no
     hw.usermem                      integer       no
     hw.memsize                      integer       no
     hw.pagesize                     integer       no
     user.cs_path                    string        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.expr_nest_max              integer       no
     user.line_max                   integer       no
     user.re_dup_max                 integer       no
     user.posix2_version             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

     The sysctl program can get or set debugging variables that have been
     identified for its display.  This information can be obtained by using
     the command:

           sysctl debug

     In addition, sysctl can extract information about the filesystems that
     have been compiled into the running system.  This information can be
     obtained by using the command:

           sysctl vfs

     By default, only filesystems that are actively being used are listed.
     Use of the -A flag lists all the filesystems compiled into the running


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

           sysctl kern.maxproc

     To set the maximum number of processes allowed in the system to 1000, one
     would use the request:

          sysctl -w kern.maxproc=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

     Information about the system's swap space usage may be obtained with:

           sysctl vm.swapusage


     <sys/sysctl.h>        definitions for top level identifiers, second level
                           kernel and hardware identifiers, and user level
     <sys/socket.h>        definitions for second level network identifiers
     <sys/gmon.h>          definitions for third level profiling identifiers
     <vm/vm_param.h>       definitions for second level virtual memory identi-
     <netinet/in.h>        definitions for third level Internet identifiers
                           and fourth level IP identifiers
     <netinet/icmp_var.h>  definitions for fourth level ICMP identifiers
     <netinet/udp_var.h>   definitions for fourth level UDP identifiers




     sysctl first appeared in 4.4BSD.

BSD                            September 4, 2012                           BSD

Mac OS X 10.8 - Generated Tue Sep 4 11:23:19 CDT 2012
© 2000-2024
Individual documents may contain additional copyright information.