# exec

Run a shell command and return combined output.

```js
exec(command, asRoot = false)
```

## Arguments

| Argument | Type | Meaning |
| --- | --- | --- |
| `command` | string | Shell command. |
| `asRoot` | boolean | Default false; true requests root. |

## Returns

Combined output string. Service failures and the 30-second timeout throw.

## Example

```js
console.log(exec("id -u"));
```

## Notes

A nonzero shell exit code is not automatically a JavaScript exception. Use execResult for reliable status checks.

[All JavaScript APIs](https://mcp.applesauceos.com/doc/api.md) · [Automation playbook](https://mcp.applesauceos.com/doc/ai.md)
