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.\" $FreeBSD$ 26.\" 27.Dd June 20, 2021 28.Dt KENV 1 29.Os 30.Sh NAME 31.Nm kenv 32.Nd list or modify the kernel environment 33.Sh SYNOPSIS 34.Nm 35.Op Fl l | s 36.Op Fl hNq 37.Nm 38.Op Fl qv 39.Ar variable Ns Op = Ns Ar value 40.Nm 41.Op Fl q 42.Fl u 43.Ar variable 44.Sh DESCRIPTION 45The 46.Nm 47utility will list all variables in the kernel environment if 48invoked without arguments. 49.Pp 50If the 51.Fl l 52option is specified, then the static environment provided by 53.Xr loader 8 54will be listed instead. 55Similarly, the 56.Fl s 57option will list the static environment defined by the kernel config. 58Both of the 59.Fl l 60and 61.Fl s 62options are dependent on the kernel being configured to preserve early kernel 63environments. 64The default kernel configuration does not preserve these environments. 65.Pp 66If the 67.Fl h 68option is specified, it will limit the report to kernel probe hints. 69If an optional 70.Ar variable 71name is specified, 72.Nm 73will only report that value. 74If the 75.Fl N 76option is specified, 77.Nm 78will only display variable names and not their values. 79If the 80.Fl u 81option is specified, 82.Nm 83will delete the given environment variable. 84If the environment variable is followed by an optional 85.Ar value , 86.Nm 87will set the environment variable to this value. 88.Pp 89If the 90.Fl q 91option is set, warnings normally printed as a result of being unable to 92perform the requested operation will be suppressed. 93.Pp 94If the 95.Fl v 96option is set, the variable name will be printed out for the 97environment variable in addition to the value when 98.Nm 99is executed with a variable name. 100.Pp 101Variables can be added to the kernel environment using the 102.Pa /boot/loader.conf 103file, or also statically compiled into the kernel using the statement 104.Pp 105.Dl Ic env Ar filename 106.Pp 107in the kernel config file. 108The file can contain lines of the form 109.Pp 110.Dl name = "value" # this is a comment 111.Pp 112where whitespace around 113.Sq name 114and 115.Sq = , 116and everything after a 117.Sq # 118character, are ignored. 119Almost any printable character except 120.Sq = 121is acceptable as part of a name. 122Quotes are optional and necessary only if the value contains whitespace. 123.Sh EXAMPLES 124Show kernel probe hints variable names and filter for the uart 125device 126.Bd -literal -offset indent 127$ kenv -h -N | grep uart 128hint.uart.0.at 129hint.uart.0.flags 130hint.uart.0.irq 131hint.uart.0.port 132hint.uart.1.at 133hint.uart.1.irq 134hint.uart.1.port 135.Ed 136.Pp 137Show the value of a specific variable: 138.Bd -literal -offset indent 139$ kenv hint.uart.1.at 140isa 141.Ed 142.Pp 143Same as above but adding the name of the variable in the report: 144.Bd -literal -offset indent 145$ kenv -v hint.uart.1.at 146hint.uart.1.at="isa" 147.Ed 148.Pp 149Try to delete a variable and suppress warnings if any: 150.Bd -literal -offset indent 151$ kenv -q -u hint.uart.1.at 152.Ed 153.Pp 154Set the value of the 155.Ev verbose_loading 156variable 157.Bd -literal -offset indent 158$ kenv verbose_loading="YES" 159verbose_loading="YES" 160.Ed 161.Sh SEE ALSO 162.Xr kenv 2 , 163.Xr config 5 , 164.Xr loader.conf 5 , 165.Xr loader 8 166.Sh HISTORY 167The 168.Nm 169utility appeared in 170.Fx 4.1.1 . 171