# Run a command

> Run a command or open an interactive shell inside a computer

> Nevia is in beta and open to selected teams. Public launch in Dec 2026. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/computers/exec

You need the [CLI installed and signed in](https://nevia.cloud/docs/get-started/quickstart.md) and a
[selected workspace](https://nevia.cloud/docs/workspaces/select.md) where you have the admin or editor role.
Use the `demo` computer from [Create a computer](https://nevia.cloud/docs/computers/create.md), with an
image that includes `sh`.

## Check the computer

```bash
nevia status demo
```

The state must be `ready`, with no pending transition. If the computer is sleeping,
[wake it first](https://nevia.cloud/docs/computers/lifecycle.md). Exec does not wake a computer.

## Run the command

Print a message inside the computer's primary container:

```bash
nevia exec demo -- sh -c 'echo hello'
```

You should see:

```text
hello
```

Everything after `--` runs inside the computer. Exec does not start a shell, so wrap
the command in `sh -c` when you need shell syntax.

The CLI streams the command's output and exits with its status. Check the exit code
right after the command:

```bash
echo $?
```

`0` means the command succeeded.

Wait for the command to finish before you sleep, checkpoint or delete the computer.
Each of those can interrupt an exec session. See
[Computer lifecycle states](https://nevia.cloud/docs/reference/computer-lifecycle.md).

[`nevia exec`](https://nevia.cloud/docs/reference/cli/exec.md) lists the command options. The
[exec API reference](https://nevia.cloud/docs/reference/api/computers/execComputer.md) covers request limits
and errors.

## Set environment variables

Each run gets the computer's stored env, with secrets and variables at their current
values. Add `-e KEY=value` to set or override a variable for one run:

```bash
nevia exec demo -e LOG_LEVEL=debug -- ./run.sh
```

Use `-e secrets.NAME` or `-e variables.NAME` to take a value from the workspace. Nevia
resolves it on each run. For the full rules, see
[Computer environment variables](https://nevia.cloud/docs/reference/computer-env.md). To manage the values,
see [Give computers secrets and variables](https://nevia.cloud/docs/workspaces/secrets-and-variables.md).

## Interactive execution

Open a shell inside the computer from your local terminal:

```bash
nevia exec demo
```

With no command, Nevia opens the computer's shell and allocates a terminal for you.
Type a few commands:

```sh
echo hello
pwd
```

You see `hello` and the working directory inside the computer. Run `exit` to close the
shell and return to your local terminal.

To run a specific program with a terminal, put it after `--`:

```bash
nevia exec demo -t -- sh
```

`-t` enables interactive input and forwards terminal resizes. It needs a local terminal
for input and output. A shell opened with no command requests one on its own. To stream
input without a terminal, use `-i` alone.

Each `nevia exec -i` or `-t` starts a new shell with the same env as one-shot exec. See
[Interactive sessions](https://nevia.cloud/docs/workspaces/secrets-and-variables.md#interactive-sessions)
for what a session URL can reach.

Sessions expire after one hour. Set another duration, up to 12 hours, with `--ttl`:

```bash
nevia exec demo --ttl 2h
```
