# `getenv`, `setenv`

_Get or set an environment variable_

## `getenv`

_Get the value of an environment variable_
```syntax
getenv x     getenv[x]
```

Where `x` is a symbol atom naming an environment variable, returns its value as a string.
Where `x` is a symbol vector, returns a list of strings.
```q
q)getenv `SHELL
"/bin/bash"
q)getenv `UNKNOWN      / returns empty if variable not defined
""
```

To get all the environment variables as a dictionary, use `os.env` from the [OS module](../modules/os/os.md#env).
```q
q)os:use`kx.os
q)type os.env[]
99h
```

## `setenv`

_Set the value of an environment variable_
```syntax
x setenv y     setenv[x;y]
```

Where

- `x` is a symbol atom
- `y` is a string

sets the environment variable named by `x` in the current process, and in processes it starts afterwards.
```q
q)`RTMP setenv "/home/user/temp"
q)getenv `RTMP
"/home/user/temp"
q)\echo $RTMP
"/home/user/temp"
q)getenv `RTMP`UNKNOWN
"/home/user/temp"
""
```

Changing `TZ` with `setenv` takes effect immediately for [`gtime` and `ltime`](gtime.md).

----

[`get`, `set`](get.md)


[Environment](by-topic.md#environment)
