# unikraft instances exec

Execute a command on an instance which has the sandbox plugin
loaded.

The environment given with `--env` is the whole environment the
command sees, not an addition to it.

Standard input is forwarded to the command only when it is
redirected from a file or a pipe. Run from a terminal, the command
sees an empty standard input and cannot be typed at.


```
unikraft instances exec <target> <command> ... [flags]
```

## Examples

Execute a command on an instance:

```bash
unikraft instance exec my-instance -- echo hello
```

Execute a command in a specific working directory:

```bash
unikraft instance exec my-instance --dir /var/lib/app -- ls -la
```

Execute a command with environment variables set:

```bash
unikraft instance exec my-instance -e DEBUG=true -- ./start.sh
```

## Options

```
  -w, --dir dir               Directory to execute the command from.
  -e, --env <key>=<value>     Environment variable.
  --plugin name               Name of the sandbox plugin to use. (default sandbox)
```

## Options inherited from parent commands

```
  --config file               Path to the configuration file.
  --log-level level           Set the logging level. (default info)
  --log-type type             Set the log type. (default text)
  --profile name              Set the current profile.
  --telemetry                 Toggle usage analytics. (default true)
  --timeout duration          Set a deadline for the command (e.g. 30s, 5m, 1h).
```

## See Also

* [`unikraft instances`](../instances.mdx): Manage Unikraft Cloud instances.

