> ## 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

**-d, --detach** `boolean` (default: false)

Start the command, print its execution ID, and return without waiting for completion.

**--show\_all** `boolean` (default: false)

Include Devboxes owned by other workspace members when selecting a Devbox.

## Related topics

> [card] [Execute commands](https://namespace.so/docs/devbox/exec.md)
>
> Learn how executions and retained logs work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.