shell command opens a full interactive terminal inside a running sandbox. It connects via WebSocket and supports everything you’d expect from a local terminal — colors, tab completion, vim, top, and terminal resizing.
Opening a Shell
Ctrl+D or type exit to disconnect.
oc shell <id>
Creates a PTY session and opens a bidirectional WebSocket connection to the sandbox.
| Flag | Type | Default | Description |
|---|---|---|---|
--shell | string | /bin/bash | Shell binary to use |
Using a Different Shell
How It Works
- Get sandbox info — Fetches the sandbox’s direct worker URL and auth token from the control plane
- Create PTY — Sends your terminal dimensions to the worker to create a PTY session
- WebSocket connect — Opens a persistent WebSocket to the worker for bidirectional I/O
- Raw terminal mode — Puts your local terminal into raw mode so keystrokes are forwarded directly
- Resize handling — Listens for
SIGWINCHand sends resize events when you resize your terminal window - Cleanup — On exit, restores your terminal, closes the WebSocket, and destroys the remote PTY session
Tips
Create and Shell In One Line
Interactive Tools Work
Full-screen terminal applications work as expected:Terminal Resizing
Resize your terminal window at any time — the remote PTY automatically adjusts to match your new dimensions.When to Use Shell vs Exec
| Use Case | Command |
|---|---|
| Run a single command and capture output | oc exec |
| Script or automation | oc exec |
| Interactive development | oc shell |
| Debugging | oc shell |
| Long-running interactive sessions | oc shell |