Jupyter vs Executable Runbooks for Bash
You want to run bash in a notebook-style interface. Two main approaches exist: Jupyter Notebook and executable runbooks.
Which is better? It depends on your use case. Here’s an honest comparison.
What We’re Comparing
Jupyter Notebook: The data science standard. Python-first, but supports bash via magic commands or kernels.
Executable Runbooks: Markdown files with code blocks that execute directly. Tools like Stew turn standard Markdown into runnable procedures.
Both offer cell-based execution. The differences are in everything else.
Format and Portability
Jupyter Notebook
Jupyter uses .ipynb files, which are JSON:
{
"cells": [{
"cell_type": "code",
"source": ["!kubectl get pods"],
"outputs": [{
"name": "stdout",
"text": ["NAME READY STATUS\n"]
}]
}],
"metadata": { ... }
}
Pros:
- Rich metadata storage
- Outputs saved in file
- Widely recognized format
Cons:
- Not human-readable
- Horrible git diffs
- Requires Jupyter to edit
- Outputs bloat file size
Executable Runbooks
Executable runbooks use standard Markdown:
# Check Pods
```bash
kubectl get pods
```
Pros:
- Human-readable everywhere
- Clean git diffs
- Edit in any text editor
- Renders on GitHub
Cons:
- Outputs not saved in file
- Less metadata by default
Winner for ops teams: Executable runbooks. Clean diffs and universal readability matter more than embedded outputs.
Execution Model
Jupyter Notebook
When you run bash in Jupyter Notebook:
- Browser sends request to Jupyter server
- Server routes to Python kernel
- Kernel spawns subprocess for bash
- Output returns through the same chain
Browser → Server → Kernel → Subprocess → Output
Latency: 100-500ms per cell, plus server startup.
Executable Runbooks
Direct execution:
- Tool parses Markdown
- Tool runs bash directly
Tool → Bash → Output
Latency: Near-instant, no server required.
Winner: Executable runbooks. Simpler architecture means faster execution.
SSH and Remote Execution
Jupyter Notebook
No native SSH support. Workarounds:
# Single commands work
!ssh server "hostname"
# Interactive sessions fail
!ssh -t server "sudo systemctl restart app" # ❌
# Tunneling is complex
# Requires manual setup outside Jupyter
Executable Runbooks
SSH as first-class feature:
```bash @production-server
kubectl get pods
```
The tool handles connection, authentication, and session management.
Winner: Executable runbooks. SSH support is essential for infrastructure work.
Collaboration
Jupyter Notebook
Sharing requires:
- Recipients have Jupyter installed
- Same environment/kernel available
- Dealing with output conflicts in version control
Code review is painful:
- "source": ["!kubectl get pods -n production"],
+ "source": ["!kubectl get pods -n staging"],
"outputs": [{
- "text": ["pod-abc Running\npod-def Running\n"]
+ "text": ["pod-xyz Running\n"]
}]
Executable Runbooks
Sharing is simple:
- It’s Markdown—works everywhere
- No special tools to view
- Diffs show exactly what changed
-kubectl get pods -n production
+kubectl get pods -n staging
Winner: Executable runbooks. Simpler format means easier collaboration.
Learning Curve
Jupyter Notebook
If you know Python, Jupyter is intuitive:
- Widely used in data science
- Good documentation
- Many tutorials available
Learning bash-in-Jupyter specifically:
- Magic commands (
!,%%bash) - Subprocess quirks
- Environment variable handling
Executable Runbooks
If you know Markdown and bash:
- Write Markdown you already know
- Code blocks work as expected
- Tool-specific features are minimal
Winner: Depends on background. Data scientists know Jupyter. Ops engineers know bash and Markdown.
Use Case: Data Analysis with Shell
You’re analyzing data, occasionally shelling out:
# Load data
import pandas as pd
df = pd.read_csv("data.csv")
# Check disk space
!df -h
# Process in Python
results = df.groupby("category").sum()
# Upload results
!aws s3 cp results.csv s3://bucket/
Best tool: Jupyter Notebook. The Python integration is the point.
Use Case: Kubernetes Operations
You’re managing a cluster:
# Check failing pods
```bash
kubectl get pods --field-selector=status.phase!=Running
```
# Get logs from problematic pod
```bash
kubectl logs pod-xyz --tail=100
```
# Restart deployment
```bash
kubectl rollout restart deployment/api
```
Best tool: Executable runbooks. No Python needed, SSH support matters.
Use Case: Incident Response
It’s 3am, production is down.
With Jupyter
- Open browser
- Navigate to Jupyter
- Wait for server (if not running)
- Open notebook
- Wait for kernel
- Start running cells
Time to first command: 2-3 minutes.
With Executable Runbooks
- Open terminal
- Run
stew incident-response.md - Start running cells
Time to first command: 10 seconds.
Best tool: Executable runbooks. Speed matters during incidents.
Use Case: Team Onboarding
New engineer learning your infrastructure:
With Jupyter
- Install Jupyter
- Install dependencies
- Configure kernels
- Clone notebook repo
- Start server
- Begin learning
With Executable Runbooks
- Clone repo
- Install tool
- Start running Markdown files
- Begin learning
Both work, but executable runbooks have less setup.
Head-to-Head Summary
| Aspect | Jupyter Notebook | Executable Runbooks |
|---|---|---|
| Format | JSON (.ipynb) | Markdown |
| Git diffs | Noisy | Clean |
| Edit anywhere | ❌ Needs Jupyter | ✅ Any editor |
| Startup time | Slow (server + kernel) | Instant |
| SSH support | Workarounds only | Native |
| Python integration | ✅ Excellent | ❌ Bash only |
| Learning curve | Familiar to data scientists | Familiar to ops |
| Incident response | Too slow | Built for it |
When to Choose Jupyter
- You’re mixing Python and bash
- Data analysis is the primary task
- Your team already uses Jupyter
- You need Python visualization libraries
When to Choose Executable Runbooks
- Bash is the primary language
- You need SSH support
- You want git-friendly format
- Speed matters (incidents, ops)
- Team includes non-Python users
The Verdict
If you’re searching “how to run bash in Jupyter Notebook” for data science, use Jupyter. It’s the right tool.
If you’re searching for operations, incident response, or infrastructure work, executable runbooks are purpose-built for that workflow.
Stew provides executable runbooks for ops teams. Write Markdown, run bash step-by-step, execute locally or over SSH.
Join the waitlist and try the right tool for the job.