Lesson 6.1: Common command line shells
sh, bash, dash, zsh and fish: where they come from and how they differ; login vs interactive shells; which shell you use, which are installed, starting a child shell and changing your login shell with chsh.
13 min
You will learn to
- Name the common shells and what sets them apart
- Explain login, interactive and non-interactive shells
- Find your login shell and the installed shells
- Run a command in a child shell with bash -c
- Change a login shell with chsh
Key terms
- sh (Bourne shell)
- The original Unix shell from 1979 and today the name of the POSIX standard shell. Scripts that start with #!/bin/sh should use only portable features.
- bash
- The GNU Bourne-Again Shell: sh plus history, arrays, [[ ]] tests and much more. Default interactive shell on most Linux distributions.
- dash
- The Debian Almquist shell: small and fast, used as /bin/sh on Debian and Ubuntu for system scripts.
- zsh and fish
- Interactive shells with richer completion and themes. zsh is the default on macOS since 2019; fish is designed to be friendly out of the box but isn't sh-compatible.
- Login, interactive, non-interactive shell
- A login shell starts when you log in (reads ~/.profile); an interactive shell waits for your commands (reads ~/.bashrc); a non-interactive shell runs a script or bash -c and exits.
- Subshell (child shell)
- A new shell process started from the current one. It gets a copy of the exported environment; nothing it changes comes back to the parent.
← Installing software by hand · All lessons · Environment variables →