xref: /freebsd/bin/kenv/kenv.1 (revision 2008043f386721d58158e37e0d7e50df8095942d)
1.\"-
2.\" Copyright (c) 2000  Peter Wemm <peter@FreeBSD.org>
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.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd June 20, 2021
26.Dt KENV 1
27.Os
28.Sh NAME
29.Nm kenv
30.Nd list or modify the kernel environment
31.Sh SYNOPSIS
32.Nm
33.Op Fl l | s
34.Op Fl hNq
35.Nm
36.Op Fl qv
37.Ar variable Ns Op = Ns Ar value
38.Nm
39.Op Fl q
40.Fl u
41.Ar variable
42.Sh DESCRIPTION
43The
44.Nm
45utility will list all variables in the kernel environment if
46invoked without arguments.
47.Pp
48If the
49.Fl l
50option is specified, then the static environment provided by
51.Xr loader 8
52will be listed instead.
53Similarly, the
54.Fl s
55option will list the static environment defined by the kernel config.
56Both of the
57.Fl l
58and
59.Fl s
60options are dependent on the kernel being configured to preserve early kernel
61environments.
62The default kernel configuration does not preserve these environments.
63.Pp
64If the
65.Fl h
66option is specified, it will limit the report to kernel probe hints.
67If an optional
68.Ar variable
69name is specified,
70.Nm
71will only report that value.
72If the
73.Fl N
74option is specified,
75.Nm
76will only display variable names and not their values.
77If the
78.Fl u
79option is specified,
80.Nm
81will delete the given environment variable.
82If the environment variable is followed by an optional
83.Ar value ,
84.Nm
85will set the environment variable to this value.
86.Pp
87If the
88.Fl q
89option is set, warnings normally printed as a result of being unable to
90perform the requested operation will be suppressed.
91.Pp
92If the
93.Fl v
94option is set, the variable name will be printed out for the
95environment variable in addition to the value when
96.Nm
97is executed with a variable name.
98.Pp
99Variables can be added to the kernel environment using the
100.Pa /boot/loader.conf
101file, or also statically compiled into the kernel using the statement
102.Pp
103.Dl Ic env Ar filename
104.Pp
105in the kernel config file.
106The file can contain lines of the form
107.Pp
108.Dl name = "value"  # this is a comment
109.Pp
110where whitespace around
111.Sq name
112and
113.Sq = ,
114and everything after a
115.Sq #
116character, are ignored.
117Almost any printable character except
118.Sq =
119is acceptable as part of a name.
120Quotes are optional and necessary only if the value contains whitespace.
121.Sh EXAMPLES
122Show kernel probe hints variable names and filter for the uart
123device
124.Bd -literal -offset indent
125$ kenv -h -N | grep uart
126hint.uart.0.at
127hint.uart.0.flags
128hint.uart.0.irq
129hint.uart.0.port
130hint.uart.1.at
131hint.uart.1.irq
132hint.uart.1.port
133.Ed
134.Pp
135Show the value of a specific variable:
136.Bd -literal -offset indent
137$ kenv hint.uart.1.at
138isa
139.Ed
140.Pp
141Same as above but adding the name of the variable in the report:
142.Bd -literal -offset indent
143$ kenv -v hint.uart.1.at
144hint.uart.1.at="isa"
145.Ed
146.Pp
147Try to delete a variable and suppress warnings if any:
148.Bd -literal -offset indent
149$ kenv -q -u hint.uart.1.at
150.Ed
151.Pp
152Set the value of the
153.Ev verbose_loading
154variable
155.Bd -literal -offset indent
156$ kenv verbose_loading="YES"
157verbose_loading="YES"
158.Ed
159.Sh SEE ALSO
160.Xr kenv 2 ,
161.Xr config 5 ,
162.Xr loader.conf 5 ,
163.Xr loader 8
164.Sh HISTORY
165The
166.Nm
167utility appeared in
168.Fx 4.1.1 .
169