> ## Documentation Index
> Fetch the complete documentation index at: https://opensandbox-oc-s-762ac928075c46d2828bcb22.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Shell

> Interactive terminal sessions from the CLI

## Opening a Shell

```bash theme={null}
oc shell sb-abc123
```

Opens a full interactive terminal over WebSocket. Press `Ctrl+D` or type `exit` to disconnect.

## Choosing a Shell

```bash theme={null}
oc shell sb-abc123 --shell /bin/zsh
```

Default: `/bin/bash`.

## What Works

The PTY supports everything you'd expect from a real terminal:

* **Editors:** vim, nano
* **Monitors:** top, htop
* **Tab completion** and command history
* **Colors** and ANSI escape codes
* **Terminal resizing** — automatic, resize events forwarded

Full-screen applications like `tmux` and `less` work correctly.

## Shell vs Exec

| Use Case                             | Command                 |
| ------------------------------------ | ----------------------- |
| Run a single command, capture output | `oc exec --wait`        |
| Scripting and automation             | `oc exec --wait --json` |
| Interactive development              | `oc shell`              |
| Debugging                            | `oc shell`              |

## Tips

### Create and Shell In

```bash theme={null}
oc shell $(oc create --json | jq -r '.sandboxID')
```

### Shell with Custom Environment

Set up the environment before shelling in:

```bash theme={null}
ID=$(oc create --json | jq -r '.sandboxID')
oc exec $ID --wait -- bash -c 'echo "export PATH=/app/bin:\$PATH" >> ~/.bashrc'
oc shell $ID
```

<Tip>
  SDK usage: [Interactive Terminals](/sandboxes/interactive-terminals). Full flags: [CLI Reference](/reference/cli#oc-shell).
</Tip>
