Skip to content

Linux playground: CLI tools in your browser

Trying a command-line tool usually means installing it first, on a machine you’d quite like to keep working. Here’s one you needn’t worry about: a real Linux machine, running in your browser tab, with most of the command-line tools the guides cover already installed and configured the way they recommend. Press the button, wait a few seconds, type.

Downloads about 20 MB, then runs entirely in this tab.
Best with a physical keyboard.

Not running

It is not a simulation, and it doesn’t run on anyone else’s server. An x86 emulator compiled to WebAssembly runs Alpine Linux on your own CPU, inside the tab, then forgets the lot when you close it. Break whatever you like: Reset, in the bottom bar’s ⋮ menu, restores it from a snapshot in about the time it takes to regret rm -rf ~.

The buttons marked ▶︎ Try it here and throughout the guides type their command into this machine and stop short of the final Enter. That one is yours.

You needn’t stay on this page, either. The terminal icon in the site’s header, or Ctrl+`, opens the machine on any other, so you can type along with a guide, and it follows you from page to page.

And Share in the bottom bar turns a command into a link to send.

ForInstalled
ShellsBash (the login shell), and Zsh with the minimal .zshrc, autosuggestions and syntax highlighting
Multiplexerstmux with the guide’s starter config, and Zellij
PromptStarship, on its defaults
EditorNeovim with the guide’s config, plugins and all
The starter packeza, bat, ripgrep, fd, zoxide, fzf and delta
Its honourable mentionsdust, duf, btop, sd, hyperfine, tldr (tealdeer), jq and direnv
Everything elsegit (with delta as its pager), htop, ncdu, curl, dig and less, and sudo with no password
The toyscowsay, fortune, figlet, lolcat, boxes, sl, cmatrix, asciiquarium, pipes.sh, cbonsai, nyancat, fastfetch, genact and tty-clock

There is also a ~/demo directory: a small, pointless project with a few commits, an uncommitted change, a JSON file, an .envrc in api/ and a log full of requests. It exists so the examples have something to chew on. The jq guide’s servers.json, response.json and events.ndjson are in ~ as well, as are the awk cheat sheet’s access.log and orders.csv, so both guides’ examples run as printed; the awk guide also gets /srv/backups, a disk that is permanently 88% full. ~/strict-mode holds the Bash strict mode guide’s scripts, ~/projects/shop is the direnv guide’s project, and ~/fonts/specimen.ts is six lines of ligature bait for the terminal fonts article.

fzf with a bat preview pane, over the demo project:

Terminal window
cd ~/demo && fzf --preview 'bat --color=always {}'

Then press Ctrl+R at the prompt for fuzzy history search, and Ctrl+T to fuzzy-find a path into the command you’re typing. ripgrep and fd do the searching; note neither looks in logs/, because .gitignore says not to:

Terminal window
rg TODO ~/demo
Terminal window
fd -e py . ~/demo

jq on the demo’s user list:

Terminal window
jq '.users[] | select(.active) | .name' ~/demo/data.json

And delta on the uncommitted change, since git already pipes through it:

Terminal window
cd ~/demo && git diff

tmux, with the starter config: Ctrl+B | and Ctrl+B - split, the mouse works, and Ctrl+B d detaches. tmux attach brings it back.

Terminal window
tmux new -s demo

Zellij, for comparison, explains its own keys along the bottom of the screen. It is the heaviest program here by a distance, so give it a moment to start:

Terminal window
zellij

direnv refuses the demo’s .envrc until you allow it, then loads it at the next prompt:

Terminal window
cd ~/demo/api && direnv allow
Terminal window
tldr tar
Terminal window
eza -l --git --icons=auto ~/demo
Terminal window
dust /usr
Terminal window
hyperfine --warmup 2 'rg TODO ~/demo' 'grep -r TODO ~/demo'

duf, btop, htop and ncdu need no arguments. zsh swaps shells, and nvim is there for anyone who would like to practise leaving it. It comes set up as in the Neovim guide, plugins and all.

The terminal test is installed as terminal-test. Here it measures xterm.js, the terminal this page draws with, which turns out to be better at colour than at pictures:

Terminal window
terminal-test

The toys are installed too: cows, rainbows, a steam locomotive and an aquarium, all of which read and write text like the serious tools, and none of which do anything useful with it.

Terminal window
fortune -s | cowsay | lolcat

Explaining a command in a forum post works about as well as explaining a joke. Showing it works better: Share in the bottom bar makes a link that opens this machine in the reader’s tab with your command typed at the prompt, and the final Enter left to them.

It takes whatever is on the prompt, or if that’s empty, the last command you ran, along with the directory it was in, and lets you check and edit both. Copy link gives you the link on its own; Copy as Markdown, for GitHub and forums, puts the command in a code block with the link under it.

The command travels in the link itself, after the #, so it never reaches a server. A command that sticks to what’s installed and the sample files works for anyone; one that needs apk add or HTTPS won’t, since the network is mostly imaginary.

It is a real machine, but it is a real machine on a short lead:

  • The network is mostly imaginary. The emulator replays the guest’s plain-HTTP requests through the browser’s own fetch(), which means they arrive as your browser, from this page, and only sites that allow cross-origin requests answer at all. Most don’t. HTTPS, SSH and every other port don’t work, which rules out apk add, git clone and the terminal test’s usual curl | sh, and is why everything comes pre-installed. DNS does work: dig gets real answers, over DNS-over-HTTPS. To see what your requests look like from the other end:

    Terminal window
    curl -s http://httpbin.org/get | jq .headers

    curl, it turns out, is now your browser.

  • ping always succeeds, whatever you point it at. The emulator answers it itself, out of politeness.

  • It is slow. An emulated 32-bit PC runs at a fraction of native speed, so hyperfine’s numbers measure the emulator, and Zellij takes a while to arrive.

  • It’s best with a physical keyboard. A phone can type into it, and the keyboard button in the bottom bar supplies Ctrl, Esc, Tab and the arrows, but it’s still typing on glass.

  • Nothing persists for long. It survives moving between pages, but reload or close the tab and it’s factory fresh. Nothing you type leaves your browser.

The machine is v86, an x86 emulator written in Rust and JavaScript and compiled to WebAssembly, running Alpine Linux built from a Dockerfile. The terminal is xterm.js, wired to the guest’s virtio console.

Two tricks keep it fast enough to bother with. The first is a snapshot: rather than booting from scratch, which takes a minute or so, the page downloads the machine’s memory as it was at its first prompt and resumes from there. The second is that the disk is fetched lazily: the root filesystem is stored as one download per file, and the browser only fetches a binary when the guest first reads it. Try zellij and you download Zellij; never try it and you never do.

Following a link doesn’t lose the machine, either: the old page saves its state to IndexedDB, and the next one restores it.

Want more to type? The Linux one-liners are a page of pipelines worth knowing by heart, with this machine beside them to run them in. Found a tool you like? The modern CLI starter pack has the install commands for your own machine, the tmux guide explains what you just split, and Starship is the prompt you’ve been looking at all along.

Find terminal ninja useful? Support it on Ko-fi