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

# Befehle in der Sandbox ausführen

export const SandboxCliConfigHint = () => {
  if (typeof document === "undefined") {
    return null;
  } else {
    return <Note>Before running the command-line related example code in this document, please refer to the <Link href="/docs/de/guides/sandbox-cli">tutorial</Link> to install the CLI and complete <Link href="/docs/de/guides/sandbox-cli-auth">authentication</Link>.</Note>;
  }
};

<SandboxCliConfigHint />

Sie können Befehle in einer laufenden Sandbox ausführen und deren Ausgabe mit dem folgenden Befehl erhalten.

```bash Bash icon="terminal" theme={"system"}
novita-sandbox-cli sandbox exec <sandbox-id> <command>
```

### Ausführungsoptionen

Mit dem Flag `--background` können Sie einen Befehl im Hintergrund ausführen und sofort zurückkehren. Der Befehl gibt die Prozess-ID (PID) auf stderr aus:

```bash Bash icon="terminal" theme={"system"}
novita-sandbox-cli sandbox exec --background <sandbox-id> "sleep 60 && echo done"
```

Das Flag `--cwd` gibt das Arbeitsverzeichnis für den Befehl an.

```bash Bash icon="terminal" theme={"system"}
novita-sandbox-cli sandbox exec --cwd /home/user <sandbox-id> ls
```

Das Flag `--user` gibt den Benutzer an, unter dem der Befehl ausgeführt wird.

```bash Bash icon="terminal" theme={"system"}
novita-sandbox-cli sandbox exec --user root <sandbox-id> apt-get update
```

Mit dem Flag `--env` können Sie Umgebungsvariablen festlegen. Wiederholen Sie das Flag, um mehrere Variablen festzulegen.

```bash Bash icon="terminal" theme={"system"}
novita-sandbox-cli sandbox exec --env NODE_ENV=production --env DEBUG=true <sandbox-id> node app.js
```
