> ## Documentation Index
> Fetch the complete documentation index at: https://docs.machine0.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Env Sets

> CLI reference for managing environment variable sets.

Create named sets of environment variables and inject them into VMs at creation time. Variables are written to `/etc/environment` and `/etc/profile.d/machine0-env.sh` via cloud-init.

```bash theme={"theme":"css-variables"}
machine0 env new production
machine0 env set production DATABASE_URL=postgres://... REDIS_URL=redis://...
machine0 new my-vm --env production
```

## env ls

```bash theme={"theme":"css-variables"}
machine0 env ls
machine0 env ls --json
```

***

## env get

Show env set details and variables.

```bash theme={"theme":"css-variables"}
machine0 env get <name>
```

***

## env new

```bash theme={"theme":"css-variables"}
machine0 env new <name>
```

Creates an empty env set. Add variables with `env set`.

***

## env set

Add or update variables in an env set.

```bash theme={"theme":"css-variables"}
machine0 env set <name> <KEY=VALUE...>
```

```bash theme={"theme":"css-variables"}
machine0 env set production DATABASE_URL=postgres://localhost/mydb
machine0 env set production API_KEY=sk_live_123 LOG_LEVEL=info
```

Keys must be valid POSIX names (`A-Z`, `a-z`, `0-9`, `_`, starting with a letter or underscore). Values cannot contain newlines, carriage returns, double quotes, or null bytes.

***

## env unset

Remove variables from an env set.

```bash theme={"theme":"css-variables"}
machine0 env unset <name> <KEY...>
```

```bash theme={"theme":"css-variables"}
machine0 env unset production LOG_LEVEL DEBUG
```

***

## env rm

Delete an env set.

```bash theme={"theme":"css-variables"}
machine0 env rm <name>
```

VMs that were created with the deleted env set are not affected — variables are baked in at creation time.

***

## Limits

| Limit             | Value |
| ----------------- | ----- |
| Variables per set | 100   |
| Sets per user     | 50    |
| Value size        | 4 KB  |
| Total set size    | 64 KB |

## How injection works

Variables are injected once at VM creation via cloud-init into two files. Both are needed because Linux reads environment variables from different places depending on context:

* `/etc/environment` — read by PAM and systemd (services, cron jobs, non-login sessions)
* `/etc/profile.d/machine0-env.sh` — sourced by login shells (SSH sessions)

Updating an env set after creation does not affect already-running VMs.

<Warning>
  Env sets are not supported with NixOS images yet. NixOS uses declarative Nix configuration instead of cloud-init.
</Warning>
