]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/sysctl/sysctl.8
contrib/tzdata: import tzdata 2022c
[FreeBSD/FreeBSD.git] / sbin / sysctl / sysctl.8
1 .\" Copyright (c) 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     From: @(#)sysctl.8      8.1 (Berkeley) 6/6/93
29 .\" $FreeBSD$
30 .\"
31 .Dd June 30, 2022
32 .Dt SYSCTL 8
33 .Os
34 .Sh NAME
35 .Nm sysctl
36 .Nd get or set kernel state
37 .Sh SYNOPSIS
38 .Nm
39 .Op Fl bdehiNnoTtqWx
40 .Op Fl B Ar bufsize
41 .Op Fl f Ar filename
42 .Ar name Ns Op = Ns Ar value Ns Op , Ns Ar value
43 .Ar ...
44 .Nm
45 .Op Fl bdehNnoTtqWx
46 .Op Fl B Ar bufsize
47 .Fl a
48 .Sh DESCRIPTION
49 The
50 .Nm
51 utility retrieves kernel state and allows processes with appropriate
52 privilege to set kernel state.
53 The state to be retrieved or set is described using a
54 .Dq Management Information Base
55 .Pq Dq MIB
56 style name, described as a dotted set of
57 components.
58 .Pp
59 The following options are available:
60 .Bl -tag -width indent
61 .It Fl A
62 Equivalent to
63 .Fl o a
64 (for compatibility).
65 .It Fl a
66 List all the currently available values except for those which are
67 opaque or excluded from listing via the
68 .Dv CTLFLAG_SKIP
69 flag.
70 This option is ignored if one or more variable names are specified on
71 the command line.
72 .It Fl b
73 Force the value of the variable(s) to be output in raw, binary format.
74 No names are printed and no terminating newlines are output.
75 This is mostly useful with a single variable.
76 .It Fl B Ar bufsize
77 Set the buffer size to read from the
78 .Nm
79 to
80 .Ar bufsize .
81 This is necessary for a
82 .Nm
83 that has variable length, and the probe value of 0 is a valid length, such as
84 .Va kern.arandom .
85 .It Fl d
86 Print the description of the variable instead of its value.
87 .It Fl e
88 Separate the name and the value of the variable(s) with
89 .Ql = .
90 This is useful for producing output which can be fed back to the
91 .Nm
92 utility.
93 This option is ignored if either
94 .Fl N
95 or
96 .Fl n
97 is specified, or a variable is being set.
98 .It Fl f Ar filename
99 Specify a file which contains a pair of name and value in each line.
100 .Nm
101 reads and processes the specified file first and then processes the name
102 and value pairs in the command line argument.
103 .It Fl h
104 Format output for human, rather than machine, readability.
105 .It Fl i
106 Ignore unknown OIDs.
107 The purpose is to make use of
108 .Nm
109 for collecting data from a variety of machines (not all of which
110 are necessarily running exactly the same software) easier.
111 .It Fl N
112 Show only variable names, not their values.
113 This is particularly useful with shells that offer programmable
114 completion.
115 To enable completion of variable names in
116 .Xr zsh 1 Pq Pa ports/shells/zsh ,
117 use the following code:
118 .Bd -literal -offset indent
119 listsysctls () { set -A reply $(sysctl -AN ${1%.*}) }
120 compctl -K listsysctls sysctl
121 .Ed
122 .Pp
123 To enable completion of variable names in
124 .Xr tcsh 1 ,
125 use:
126 .Pp
127 .Dl "complete sysctl 'n/*/`sysctl -Na`/'"
128 .It Fl n
129 Do not show variable names.
130 This option is useful for setting shell variables.
131 For instance, to save the pagesize in variable
132 .Va psize ,
133 use:
134 .Pp
135 .Dl "set psize=`sysctl -n hw.pagesize`"
136 .It Fl o
137 Show opaque variables (which are normally suppressed).
138 The format and length are printed, as well as a hex dump of the first
139 sixteen bytes of the value.
140 .It Fl q
141 Suppress some warnings generated by
142 .Nm
143 to standard error.
144 .It Fl T
145 Display only variables that are settable via loader (CTLFLAG_TUN).
146 .It Fl t
147 Print the type of the variable.
148 .It Fl W
149 Display only writable variables that are not statistical.
150 Useful for determining the set of runtime tunable sysctls.
151 .It Fl X
152 Equivalent to
153 .Fl x a
154 (for compatibility).
155 .It Fl x
156 As
157 .Fl o ,
158 but prints a hex dump of the entire value instead of just the first
159 few bytes.
160 .El
161 .Pp
162 The information available from
163 .Nm
164 consists of integers, strings, and opaque types.
165 The
166 .Nm
167 utility
168 only knows about a couple of opaque types, and will resort to hexdumps
169 for the rest.
170 The opaque information is much more useful if retrieved by special
171 purpose programs such as
172 .Xr ps 1 ,
173 .Xr systat 1 ,
174 and
175 .Xr netstat 1 .
176 .Pp
177 Some of the variables which cannot be modified during normal system
178 operation can be initialized via
179 .Xr loader 8
180 tunables.
181 This can for example be done by setting them in
182 .Xr loader.conf 5 .
183 Please refer to
184 .Xr loader.conf 5
185 for more information on which tunables are available and how to set them.
186 .Pp
187 The string and integer information is summarized below.
188 For a detailed description of these variable see
189 .Xr sysctl 3 .
190 .Pp
191 The changeable column indicates whether a process with appropriate
192 privilege can change the value.
193 String and integer values can be set using
194 .Nm .
195 .Bl -column security.bsd.unprivileged_read_msgbuf integerxxx
196 .It Sy "Name    Type    Changeable"
197 .It "kern.ostype        string  no"
198 .It "kern.osrelease     string  no"
199 .It "kern.osrevision    integer no"
200 .It "kern.version       string  no"
201 .It "kern.maxvnodes     integer yes"
202 .It "kern.maxproc       integer no"
203 .It "kern.maxprocperuid integer yes"
204 .It "kern.maxfiles      integer yes"
205 .It "kern.maxfilesperproc       integer yes"
206 .It "kern.argmax        integer no"
207 .It "kern.securelevel   integer raise only"
208 .It "kern.hostname      string  yes"
209 .It "kern.hostid        integer yes"
210 .It "kern.clockrate     struct  no"
211 .It "kern.posix1version integer no"
212 .It "kern.ngroups       integer no"
213 .It "kern.job_control   integer no"
214 .It "kern.saved_ids     integer no"
215 .It "kern.boottime      struct  no"
216 .It "kern.domainname    string  yes"
217 .It "kern.filedelay     integer yes"
218 .It "kern.dirdelay      integer yes"
219 .It "kern.metadelay     integer yes"
220 .It "kern.osreldate     integer no"
221 .It "kern.bootfile      string  yes"
222 .It "kern.corefile      string  yes"
223 .It "kern.logsigexit    integer yes"
224 .It "security.bsd.suser_enabled integer yes"
225 .It "security.bsd.see_other_uids        integer yes"
226 .It "security.bsd.unprivileged_proc_debug       integer yes"
227 .It "security.bsd.unprivileged_read_msgbuf      integer yes"
228 .It "vm.loadavg struct  no"
229 .It "hw.machine string  no"
230 .It "hw.model   string  no"
231 .It "hw.ncpu    integer no"
232 .It "hw.byteorder       integer no"
233 .It "hw.physmem integer no"
234 .It "hw.usermem integer no"
235 .It "hw.pagesize        integer no"
236 .It "hw.floatingpoint   integer no"
237 .It "hw.machine_arch    string  no"
238 .It "hw.realmem integer no"
239 .It "machdep.adjkerntz  integer yes"
240 .It "machdep.disable_rtc_set    integer yes"
241 .It "machdep.guessed_bootdev    string  no"
242 .It "user.cs_path       string  no"
243 .It "user.bc_base_max   integer no"
244 .It "user.bc_dim_max    integer no"
245 .It "user.bc_scale_max  integer no"
246 .It "user.bc_string_max integer no"
247 .It "user.coll_weights_max      integer no"
248 .It "user.expr_nest_max integer no"
249 .It "user.line_max      integer no"
250 .It "user.re_dup_max    integer no"
251 .It "user.posix2_version        integer no"
252 .It "user.posix2_c_bind integer no"
253 .It "user.posix2_c_dev  integer no"
254 .It "user.posix2_char_term      integer no"
255 .It "user.posix2_fort_dev       integer no"
256 .It "user.posix2_fort_run       integer no"
257 .It "user.posix2_localedef      integer no"
258 .It "user.posix2_sw_dev integer no"
259 .It "user.posix2_upe    integer no"
260 .It "user.stream_max    integer no"
261 .It "user.tzname_max    integer no"
262 .It "user.localbase     string  no"
263 .El
264 .Sh FILES
265 .Bl -tag -width ".In netinet/icmp_var.h" -compact
266 .It In sys/sysctl.h
267 definitions for top level identifiers, second level kernel and hardware
268 identifiers, and user level identifiers
269 .It In sys/socket.h
270 definitions for second level network identifiers
271 .It In sys/gmon.h
272 definitions for third level profiling identifiers
273 .It In vm/vm_param.h
274 definitions for second level virtual memory identifiers
275 .It In netinet/in.h
276 definitions for third level Internet identifiers and
277 fourth level IP identifiers
278 .It In netinet/icmp_var.h
279 definitions for fourth level ICMP identifiers
280 .It In netinet/udp_var.h
281 definitions for fourth level UDP identifiers
282 .El
283 .Sh EXIT STATUS
284 .Ex -std
285 .Sh EXAMPLES
286 For example, to retrieve the maximum number of processes allowed
287 in the system, one would use the following request:
288 .Pp
289 .Dl "sysctl kern.maxproc"
290 .Pp
291 To set the maximum number of processes allowed
292 per uid to 1000, one would use the following request:
293 .Pp
294 .Dl "sysctl kern.maxprocperuid=1000"
295 .Pp
296 Information about the system clock rate may be obtained with:
297 .Pp
298 .Dl "sysctl kern.clockrate"
299 .Pp
300 Information about the load average history may be obtained with:
301 .Pp
302 .Dl "sysctl vm.loadavg"
303 .Pp
304 More variables than these exist, and the best and likely only place
305 to search for their deeper meaning is undoubtedly the source where
306 they are defined.
307 .Sh COMPATIBILITY
308 The
309 .Fl w
310 option has been deprecated and is silently ignored.
311 .Sh SEE ALSO
312 .Xr sysctl 3 ,
313 .Xr loader.conf 5 ,
314 .Xr sysctl.conf 5 ,
315 .Xr loader 8
316 .Sh HISTORY
317 A
318 .Nm
319 utility first appeared in
320 .Bx 4.4 .
321 .Pp
322 In
323 .Fx 2.2 ,
324 .Nm
325 was significantly remodeled.
326 .Sh BUGS
327 The
328 .Nm
329 utility presently exploits an undocumented interface to the kernel
330 .Xr sysctl 9
331 facility to traverse the sysctl tree and to retrieve format
332 and name information.
333 This correct interface is being thought about for the time being.