Jupyter notebooks for your team.

Try free
← Blog

Colab Terminal: Free Since July 2025, How to Open It, Shell Commands, SSH and VS Code (2026)

Google made the Colab Terminal free for every user on 22 July 2025. How to open it, the commands worth knowing, why cd and export vanish between ! lines, what survives a restart, running jobs in the background, Google's own colab ssh and what the FAQ says about SSH on the free plan, with 12 cells we ran in a real Jupyter kernel.

Fastero Dev TeamFastero Dev Team2026-12-02

We read Colab's release notes and FAQ, the source of the code Colab uses to run ! commands, the docs of Google's Colab CLI and VS Code extension, and the script that draws the notebook page, which turns out to check cells for SSH tunnel setups before running them. Then we ran 12 notebook cells in a Jupyter kernel inside a Linux container to show what !, %cd, %env and %%bash keep from one line to the next, and how to leave a process running after a cell ends.

The short answer: yes, the Colab Terminal is free. Google's release notes for 22 July 2025 say "Terminal is now available to all users, free of charge!" Click Terminal at the bottom of the notebook, or choose Show terminal from Tools › Command palette, and you get a shell on the same runtime as your notebook, deleted along with it. From a cell, !command runs one line in bash and %%bash runs a whole cell, but cd and export don't carry over to the next ! line: use %cd and %env. For SSH, Google's Colab CLI now has colab ssh, though the FAQ still disallows SSH shells on free runtimes without compute units. Checked 2 December 2026.

Fastero

Jupyter notebooks for your team, with nothing to install.

Start a notebook or bring your .ipynb files. SQL cells query your databases with no password in the code, and a notebook runs now or on a schedule. Colleagues open it with their own login; viewers are free.

Try free →

Does Colab have a terminal on the free plan?

Yes, since 22 July 2025. Until then it was a paid extra; Chris McCormick's guide still carries the older tip that "Colab Pro also gives you the ability to open a terminal". In the notebook page's current script, the command that opens the Terminal has no plan check at all. The only thing that blocks it is Colab's own AI agent: while Gemini is running cells, Colab says "Gemini is executing. Please wait for it to finish or click stop."

Two things come installed for you, both from the release notes: the Gemini CLI since July 2025 ("Try it out in the Terminal!") and, since 16 September 2026, the Antigravity CLI. The same update moved runtimes to Ubuntu 24.04 and "Python upgraded from 3.12.13 to 3.13.15 (all images)".

A table of six ways to get a shell on a Google Colab runtime by plan: !command and %%bash cells and the Terminal panel work on the free and paid plans; the terminal in Google's VS Code extension works on both; Google's colab ssh and your own SSH server or tunnel are disallowed on free runtimes by Colab's FAQ, while paid plans with units can use colab ssh and get a warning for tunnels; a local runtime works on every plan

Ways to get a shell on a Colab runtime, by plan, from Google's FAQ, release notes, CLI docs and the notebook page's code, checked 2 December 2026.

How to open the terminal in Colab

  1. Open the notebook. If it isn't connected to a runtime yet, opening the Terminal connects it first.
  2. Click Terminal in the bar at the bottom of the notebook, or open Tools › Command palette and choose Show terminal.
  3. The Terminal opens as a tab next to the notebook, with a shell on the runtime. It's the same machine as the notebook: files you create in one are visible in the other.
  4. If the runtime goes away, the tab prints [disconnected]. A new runtime means a new, empty shell.

Colab terminal commands worth knowing

Command What it tells you
nvidia-smi The GPU, its memory and what's using it; watch -n 1 nvidia-smi refreshes it every second
free -h RAM: read the available column (our Colab RAM guide explains the crash)
df -h /content Space left on the runtime's own disk
ps aux --sort=-%mem Which processes hold the most memory
tpu-info TPU memory and use, on TPU runtimes (release notes, August 2024)
gemini Starts the Gemini CLI that comes installed

McCormick's version of the GPU tip: "You can run watch nvidia-smi there to get a live, auto-refreshing view of GPU utilization and memory".

Running shell commands from a cell: ! and %%bash

A cell doesn't need the Terminal to reach the shell. Colab swaps IPython's own ! for its code, which runs each line in /bin/bash through a pseudo-terminal; its docstring says that compared with Jupyter's version it "additionally allows input to be provided to the subprocess", which is why an install that asks [Y/n] shows an input box. Colab also has %shell and %%shell, which raise an error when the command fails.

The rules for what carries over are IPython's, and they trip people up. We ran these cells on 2 December 2026 in a Jupyter kernel (IPython 9.19.1, ipykernel 7.4.0, Python 3.13.18) inside a Debian 13 container on a Windows laptop, driven by nbclient. Colab's package list has the older IPython 7.34.0; the rules below are the same there except where noted.

In [1]:
    !echo "shell is $0"
    !echo "shell is $$0, in $(pwd), as $(whoami)"
  > shell is 0
  > shell is /usr/bin/sh, in /content, as root
 
In [2]:
    !cd /tmp && pwd
    !pwd
  > /tmp
  > /content
 
In [3]:
    %cd /tmp
    !pwd
    %cd /content
  > /tmp
  > /tmp
  > /content
 
In [4]:
    !export STAGE=dev
    !echo "STAGE is [$STAGE]"
    %env STAGE=dev
    !echo "STAGE is [$STAGE]"
  > STAGE is []
  > env: STAGE=dev
  > STAGE is [dev]
 
In [5]:
    %%bash
    cd /tmp
    export STAGE=prod
    echo "inside the %%bash cell: $(pwd), STAGE=$STAGE"
  > inside the %%bash cell: /tmp, STAGE=prod
 
In [6]:
    !echo "the next cell: $(pwd), STAGE=$STAGE"
  > the next cell: /content, STAGE=dev
 
In [7]:
    n = 3
    !seq {n}
    files = !ls /etc | head -n 3
    print(type(files).__name__, files)
    !false
    print("exit code of the last command:", _exit_code)
  > 1
  > 2
  > 3
  > SList ['adduser.conf', 'alternatives', 'apt']
  > exit code of the last command: 1

What the output shows:

  • IPython rewrites the line before the shell sees it. $0 became 0 because IPython expands $name and {expression} from Python. Its docs: "Note that $$ is used to represent a literal $." Colab's code does the same expansion. Our plain Jupyter ran /usr/bin/sh; Colab runs bash.
  • Each ! line is a new shell. !cd and !export last for that one line. %cd and %env change the notebook's own process, so later lines see them.
  • %%bash is one shell for the whole cell, and its changes end with the cell.
  • Values cross both ways. {n} puts a Python value into a command; files = !ls brings the output back as a list of lines; _exit_code holds the last command's exit status.

What persists in Colab, and what doesn't

What Next ! line Restart session Runtime deleted
cd or export inside a ! line Lost Lost Lost
%cd, %env, Python variables Kept Lost Lost
Files in /content, pip install, apt install Kept Kept Lost
A background process Kept Google doesn't say Lost
Files in your mounted Google Drive Kept Kept Kept

Colab's dialogs spell out the two big ones. Restarting: "Runtime state including all local variables will be lost." Deleting: "This runtime's files will be deleted when this runtime is deleted." A runtime is deleted when you choose Disconnect and delete runtime, when it sits idle, or at its maximum lifetime: a free notebook "can run for at most 12 hours". So keep installs in a setup cell you can rerun, and save outputs to Drive, as our Colab and Google Drive guide shows.

Background processes in Colab and their limits

A training script, a small server, or a job that writes a log while you keep working: in Colab, you can write !nohup python3 job.py > job.log 2>&1 &. Colab's code passes the whole line to bash and doesn't stop what it leaves running. Plain Jupyter refuses the trailing &, which matters if you move the notebook. The portable way is Python's own subprocess, which we ran next:

In [8]:
    %%writefile counter.py
    import time
    for i in range(1, 100_000):
        print(f"tick {i}", flush=True)
        time.sleep(1)
  > Writing counter.py
 
In [9]:
    !nohup python3 counter.py > counter.log 2>&1 &
  > OSError: Background processes not supported.
 
In [10]:
    import subprocess
    counter = subprocess.Popen(["python3", "counter.py"], stdout=open("counter.log", "w"),
                               stderr=subprocess.STDOUT, start_new_session=True)
    print("started process", counter.pid, "and the cell is already done")
  > started process 386 and the cell is already done
 
In [11]:
    !sleep 3; tail -n 1 counter.log; pgrep -af "[c]ounter.py"
  > tick 4
  > 386 python3 counter.py
 
In [12]:
    counter.terminate()
    print("exit code", counter.wait())
    !pgrep -af "[c]ounter.py" || echo "nothing left running"
  > exit code -15
  > nothing left running

The counter kept ticking after its cell finished, and terminate() stopped it (exit code -15, killed by SIGTERM). Note the [c] in the pattern: without it, pgrep -f also matches the shell running the pgrep command. Google's CLI docs give the same advice for pkill: use "a pattern that cannot match its own shell".

The limits:

  • It dies with the runtime. Nothing survives the runtime's maximum lifetime (12 hours on the free plan) or a deleted runtime; write results to Drive as you go.
  • It doesn't keep the runtime awake. The FAQ: "Idle timeouts only apply if code execution terminates", and a cell that starts a background job has terminated. Answering on the Colab CLI's issue tracker in October 2026, a contributor to the project explained: "Colab mostly depends on checking for live connections to the VM to determine whether to shut down the VM". Keep the tab open, or the SSH session described below.
  • Some background work isn't allowed on the free plan. Without compute units, the FAQ disallows "bypassing the notebook UI to interact primarily via a web UI" and "running distributed computing workers". For some known web UIs, the page shows a warning when your balance is zero: "You may be executing code that is disallowed which may terminate your runtime without warning."

Why runtimes end, and how to checkpoint a long job, is in our Colab disconnect guide.

Jupyter notebooks for your team.

Start free →

SSH into Colab: Google's colab ssh, and why the old tricks are discouraged

For years the way to SSH into Colab was to start your own SSH server on the runtime and expose it through a tunnel: the colab_ssh package (last released on 28 October 2021, and still describing itself as a way "to connect to Google Colab Notebook using an SSH Tunnel and optionally via VSCode"), or tools like tmate, ngrok and cloudflared. Colab's FAQ lists, among things "disallowed from managed Colab runtimes running free of charge, without a positive Colab compute unit balance":

  • "remote control such as SSH shells, remote desktops"

Such runtimes "may be terminated at any time without warning". The FAQ's fix: "You can remove these types of restrictions by purchasing one of our paid plans here and maintaining a positive compute unit balance." For every runtime, paid or free, it also disallows "connecting to remote proxies", without saying whether a tunnel counts. We don't read that as a ban on SSH for paid users; the FAQ's own wording limits the SSH rule to free runtimes without units.

Colab now acts on it before you run anything. The notebook page's script checks each cell for known setups, including pip install colab_ssh, tmate, sshx, a Dropbear SSH server, code-server, xrdp and Chrome Remote Desktop, and asks first: "You may be executing code that is disallowed, and this may restrict your ability to use Colab in the future." It offers Cancel execution or Continue anyway, on any plan. For the SSH-like tools it can add: "Colab has built-in SSH (Connect via SSH), so you don't need to run your own server or tunnel."

That built-in SSH is the Colab CLI's colab ssh, added on 17 July 2026. It needs a local ssh client and an Ed25519 or ECDSA key (RSA keys are refused), and it connects over a WebSocket through Colab, so you don't run a tunnel or open a port yourself:

uv tool install google-colab-cli
colab ssh                       # new runtime if you have none; shell in /content
colab ssh --gpu T4 --rm         # T4 runtime, stopped when you log out
colab ssh -s my-session -- nvidia-smi

What its docs add: a runtime accepts a limited number of SSH connections and "the limit depends on the Colab plan"; the SSH environment is minimal, though Python, pip and nvidia-smi work; and the CLI's README lists Linux and macOS only, while the SSH docs record Windows fixes in October and November 2026. On the free plan, the FAQ line above still covers SSH shells, and the docs don't say whether Google's own tool is exempt. If you're on the free plan, use the Terminal panel, which Google offers for free.

The VS Code route

Google's Colab extension for VS Code, released in November 2025, runs your local notebooks on Colab runtimes: in a notebook, choose Select Kernel › Colab › Auto Connect. It has a terminal too: run Colab: Open Terminal from the command palette, or use the Colab button above the notebook. The user guide still describes "the experimental Terminal feature", but in version 0.9.7 the extension's colab.terminal setting, which "Enables the ability to open a terminal connected to Colab runtimes", is on by default. The setup, and how it compares with the browser, is in our Colab in VS Code guide.

For a full remote workspace, VS Code's Remote-SSH extension can use colab ssh as its transport. This is the ~/.ssh/config entry Colab's own Connect via SSH dialog gives:

Host colab
  User root
  ProxyCommand colab ssh --proxy-mode -s colab
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null

Then run Remote-SSH: Connect to Host... and pick colab. Use an absolute path to colab if VS Code can't find it, as the CLI's docs advise, and the same plan caveat applies. Our Jupyter on a remote server guide covers Remote-SSH in general.

Where Fastero fits

A lot of shell work in Colab is a workaround for a job that should run on its own: a script started with nohup that dies with the runtime, a key typed into %env every session, a tab kept open so the machine stays up. If that's the job, Fastero is an AI and data platform where people and AI agents work together on a team's data, and it runs Python and notebooks without a browser:

  • Python projects and notebooks run now or on a cron schedule, on the server with no browser open. The Free plan, with no card and no end date, includes 6 hours a day of notebook and Python time.
  • Secrets reach your code as environment variables, in scheduled runs as well as interactive ones, so nothing is pasted into a cell. Each Python run keeps a log.
  • SQL cells query a saved connection with its stored credentials, instead of a tunnel to the database.
  • Machines: 1 CPU and 2 GB as standard; on Pro, a notebook can move to a bigger one, up to 8 CPUs and 32 GB ($0.40 an hour for 16 GB, $0.80 for 32 GB), charged by the second from money added to the balance.

If what you need is an interactive shell or a GPU, Colab's Terminal or your own machine is the right tool. Plans are on the pricing page.

A Python job in Fastero: main.py reads its database address from an environment variable and queries monthly revenue, and the run log below shows Succeeded with the report it printed

A Python job in Fastero, reading its database address from an environment variable, with its last run's log. Sample data.

FAQ

Is the Colab terminal free?

Yes. Google's release notes for 22 July 2025 say "Terminal is now available to all users, free of charge!" Before that it was a feature of the paid plans. It runs on your runtime, so it ends when the runtime does.

How do I open the terminal in Google Colab?

Click Terminal in the bar at the bottom of the notebook, or open Tools › Command palette and choose Show terminal. It opens in a tab beside the notebook and connects to the notebook's runtime, starting one if needed.

Why doesn't !cd work in Colab?

It does, for that one line: each ! line runs in a new shell, which exits when the line ends. Use %cd to change the notebook's directory for later lines, and %env instead of !export for environment variables.

What's the difference between ! and %%bash in Colab?

! runs a single line in its own shell and can pass Python values in and capture output back into a variable. %%bash runs a whole cell as one bash script, so variables and directory changes last until the cell ends, but not beyond it.

Can I SSH into Google Colab?

Google's Colab CLI has colab ssh, which opens a real shell on a runtime and works with VS Code's Remote-SSH. Colab's FAQ disallows SSH shells on free runtimes without compute units, so it's a paid-plan route in practice; on the free plan, use the Terminal panel.

Can I run a background process in Colab?

Yes: !nohup python3 job.py > job.log 2>&1 & works in Colab, and subprocess.Popen works anywhere. The process stops when the runtime is deleted, and it doesn't count as activity, so the runtime can still be shut down for being idle.

Does the Colab terminal work in VS Code?

Yes. Google's Colab extension has a Colab: Open Terminal command, still labelled experimental but switched on by default in version 0.9.7. For a full remote session, point VS Code's Remote-SSH at colab ssh --proxy-mode.

Sources

Read on 2 December 2026:


Try Fastero free: run the Python job you'd leave going in a Colab terminal on a cron schedule instead, with secrets as environment variables and no tab to keep open. No credit card required.

Start a notebook next to your team's data.

Python 3.11 with pandas, SQLAlchemy and seaborn, SQL cells on your databases, and scheduled runs on the Free plan. No credit card required.

Follow Fastero on LinkedIn for new articles and examples.