Andrew Mercer
on this page

Everything that happens at the command line: the shells themselves, terminal emulators and multiplexers (tmux, screen, tmate, terminator), session recording (asciinema, scriptreplay), and the utilities that glue commands together (xargs, parallel, watch, history).

Shells

sh · bash · dash · ash · zsh · fish

Which shell am I in?

echo "$0"                              # current shell (prefixed with - for a login shell)
ps -p $$ -o comm=                      # same, more reliably
echo "$SHELL"                          # your *login* shell, not necessarily the one running now
getent passwd "$USER" | cut -d: -f7    # login shell from the passwd database
ls -l /bin/sh                          # what sh actually points to
cat /etc/shells                        # shells allowed as login shells

Change your login shell with chsh -s "$(command -v zsh)". The path must be listed in /etc/shells, and the change takes effect at your next login. Keep a root or sudo session open while testing a new login shell, in case its config breaks logins.

Choosing a shell

Scripting Interactive POSIX sh compatible
dash Portable #!/bin/sh scripts, Debian system scripts No Yes
BusyBox ash Whatever runs in Alpine and minimal images Minimal Yes, plus some bash extras
bash The default for most scripts Yes Mostly, in POSIX mode
zsh Possible, but less portable than bash Excellent with configuration With emulate sh
fish Personal functions only Excellent out of the box No

A reasonable default: write scripts for #!/bin/sh when they need to run anywhere (containers, other distros), or for #!/usr/bin/env bash otherwise, and use whichever interactive shell you like. The interactive shell and the scripting shell don't have to be the same.

Other shells

  • ksh (KornShell): the ancestor of many bash features. ksh93 and the smaller mksh are still found on commercial Unix, OpenBSD (/bin/ksh is pdksh-derived), and Android.
  • tcsh: the C shell family. Its syntax is unlike sh, it was historically the FreeBSD root shell, and it is a poor choice for scripting.
  • Nushell, Elvish, and xonsh: newer shells that pass structured data (tables, records) through pipelines instead of text. Nushell is written in Rust.
in this section
* asciinema — record terminal sessions as shareable casts/
* ash — the almquist shell and busybox ash/
* bash/
* dash — the debian almquist shell/
* date — show, format, set, and calculate dates/
* fish — the friendly interactive shell/
* gnu parallel — run jobs in parallel/
* history/
* reptyr — move a running process to a new terminal/
* screen — terminal multiplexer/
* script and scriptreplay — record and replay a terminal session/
* sh — the posix shell/
* terminator — terminal emulator with split panes and groups/
* tmate — instant terminal sharing/
* tmux — terminal multiplexer/
* watch — run a command repeatedly/
* xargs — build commands from input/
* zsh — the z shell/