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

# devbox exec

> Execute a command on a Devbox.

Use `devbox exec` to run a non-interactive command on a Devbox. The execution and its output are retained so you can inspect them with `devbox logs`.

## Usage

```bash theme={null}
devbox exec [name] [-- command...] [flags]
```

A command is required. Flags for `devbox exec` must appear before the Devbox name because flag parsing stops at the first positional argument.

## Run a command and wait

```bash theme={null}
devbox exec main -- npm test
```

The command streams the execution logs and returns the remote command's result.

## Start a detached execution

```bash theme={null}
devbox exec --detach main -- ./scripts/long-build.sh
```

```text Output nocopy theme={null}
<exec-id>
```

## Options

<ResponseField name="-d, --detach" type="boolean" default="false">
  Start the command, print its execution ID, and return without waiting for completion.
</ResponseField>

<ResponseField name="--show-all" type="boolean" default="false">
  Include Devboxes owned by other workspace members when selecting a Devbox.
</ResponseField>

## Related topics

<Card title="Execute commands" icon="terminal" href="/docs/devbox/exec">
  Learn how executions and retained logs work.
</Card>
