Skip to main content
The 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

oc shell sb-abc123
You’ll be dropped into a bash shell inside the sandbox. Press Ctrl+D or type exit to disconnect.

oc shell <id>

Creates a PTY session and opens a bidirectional WebSocket connection to the sandbox.
FlagTypeDefaultDescription
--shellstring/bin/bashShell binary to use

Using a Different Shell

oc shell sb-abc123 --shell /bin/zsh
oc shell sb-abc123 --shell /bin/sh

How It Works

  1. Get sandbox info — Fetches the sandbox’s direct worker URL and auth token from the control plane
  2. Create PTY — Sends your terminal dimensions to the worker to create a PTY session
  3. WebSocket connect — Opens a persistent WebSocket to the worker for bidirectional I/O
  4. Raw terminal mode — Puts your local terminal into raw mode so keystrokes are forwarded directly
  5. Resize handling — Listens for SIGWINCH and sends resize events when you resize your terminal window
  6. Cleanup — On exit, restores your terminal, closes the WebSocket, and destroys the remote PTY session

Tips

Create and Shell In One Line

oc shell $(oc create --json | jq -r '.sandboxID')

Interactive Tools Work

Full-screen terminal applications work as expected:
# Inside the shell:
top           # Process monitor
vim file.txt  # Text editor
htop          # Interactive process viewer

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 CaseCommand
Run a single command and capture outputoc exec
Script or automationoc exec
Interactive developmentoc shell
Debuggingoc shell
Long-running interactive sessionsoc shell