# Execute commands in sandbox - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/guides/sandbox-cli-execute-commands

# Execute commands in sandbox

You can execute commands in a running sandbox and receive its output by using the following command.

Bash

```
novita-sandbox-cli sandbox exec
```

###

[​](#execution-options)

Execution options

`--background` flag lets you run a command in the background and return immediately. The command will print the process ID (PID) to stderr:

Bash

```
novita-sandbox-cli sandbox exec --background "sleep 60 && echo done"
```

`--cwd` flag specifies the working directory for the command.

Bash

```
novita-sandbox-cli sandbox exec --cwd /home/user ls
```

`--user` flag specifies the user to run the command.

Bash

```
novita-sandbox-cli sandbox exec --user root apt-get update
```

`--env` flag lets you set environment variables. Repeat the flag to set multiple variables.

Bash

```
novita-sandbox-cli sandbox exec --env NODE_ENV=production --env DEBUG=true node app.js
```

Last modified on June 4, 2026
