---
name: "kenv"
section: "1"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/kenv"
---

# kenv(1)

list or modify the kernel environment

## NAME

**kenv** – list or modify the kernel environment

## SYNOPSIS

**kenv** \[**-l** \| **-s**\] \[**-hNq**\]

**kenv** \[**-qv**\] *variable*\[=*value*\]

**kenv** \[**-q**\] **-u** *variable*

## DESCRIPTION

The **kenv** utility will list all variables in the kernel environment if invoked without arguments.

If the **-l** option is specified, then the static environment provided by [loader(8)](/loader/8.md) will be listed instead. Similarly, the **-s** option will list the static environment defined by the kernel config. Both of the **-l** and **-s** options are dependent on the kernel being configured to preserve early kernel environments. The default kernel configuration does not preserve these environments.

If the **-h** option is specified, it will limit the report to kernel probe hints. If an optional *variable* name is specified, **kenv** will only report that value. If the **-N** option is specified, **kenv** will only display variable names and not their values. If the **-u** option is specified, **kenv** will delete the given environment variable. If the environment variable is followed by an optional *value*, **kenv** will set the environment variable to this value.

If the **-q** option is set, warnings normally printed as a result of being unable to perform the requested operation will be suppressed.

If the **-v** option is set, the variable name will be printed out for the environment variable in addition to the value when **kenv** is executed with a variable name.

Variables can be added to the kernel environment using the */boot/loader.conf* file, or also statically compiled into the kernel using the statement

```
env filename
```

in the kernel config file. The file can contain lines of the form

```
name = value # this is a comment
```

where whitespace around ‘name’ and ‘=’, and everything after a ‘#’ character, are ignored. Almost any printable character except ‘=’ is acceptable as part of a name. Quotes are optional and necessary only if the value contains whitespace.

## EXAMPLES

Show kernel probe hints variable names and filter for the uart device

```
$ kenv -h -N | grep uart
hint.uart.0.at
hint.uart.0.flags
hint.uart.0.irq
hint.uart.0.port
hint.uart.1.at
hint.uart.1.irq
hint.uart.1.port
```

Show the value of a specific variable:

```
$ kenv hint.uart.1.at
isa
```

Same as above but adding the name of the variable in the report:

```
$ kenv -v hint.uart.1.at
hint.uart.1.at="isa"
```

Try to delete a variable and suppress warnings if any:

```
$ kenv -q -u hint.uart.1.at
```

Set the value of the verbose\_loading variable

```
$ kenv verbose_loading="YES"
verbose_loading="YES"
```

## SEE ALSO

[kenv(2)](/kenv/2.md), [config(5)](/config/5.md), [loader.conf(5)](/loader.conf/5.md), [loader(8)](/loader/8.md)

## HISTORY

The **kenv** utility appeared in FreeBSD 4.1.1.

## SECURITY CONSIDERATIONS

Note that unprivileged users are allowed to read from the kernel environment, unless the *security.bsd.unprivileged\_kenv\_read* sysctl is set to 0. This includes both listing the kernel environment, as well as getting a specific *variable* from the environment.
