On Unix — the progenitor of Linux — there was
/bin/sh. It was simple, by comparison to today’s shells, but it allowed you to enter commands and — most importantly — execute lists of commands. In fact, it was a simple programming language that could make decisions, loop, and do other things to allow you to write scripts that were more than just a list of programs to run. However, it wasn’t always the easiest thing to use, so in true Unix fashion, people started writing new shells. In this post, I want to point out a few shells other than the ubiquitous
bash, which is one of the successors to the old
Since the 7th Edition of Unix,
sh was actually the Bourne shell, named after its author, Stephen Bourne. It replaced the older Thompson shell written in 1971. That shell had some resemblance to a modern shell, but wasn’t really set up for scripting. It did have the standard syntax for redirection and piping, though. The PWB shell was also an early contender to replace Thompson, but all of those shells have pretty much disappeared.
You probably use
bash and, honestly, you’ll probably continue to use
bash after reading this post. But there are a few alternatives and for some people, they are worth considering. Also, there are a few special-purpose shells you may very well encounter even if your primary shell is
There are really two ways to go when creating a new shell. Unix and Linux custom, as well as several standards, assume you will have
/bin/sh available to execute scripts. Of course, a shell script can also ask for a specific interpreter using the
#! syntax. That’s how you can have scripts written in things like
That leads to two different approaches. You can create a new shell that is compatible with
sh, but extended. That’s the approach things like the Korn shell (
ksh) or the Bourne Again shell (
bash) take. On the other hand, you can completely replace the shell with something new like the C shell (practically, now,
tcsh which has pretty much replaced C shell). These shells don’t look anything like the classic shell. Of course, neither does
bash if you look at the details, but superficially, most things you can do with
sh will work with
bash, too, but
bash adds a lot more.
David Korn at AT&T wrote a shell that bears his name. If you only know
bash, you’d be a lot more comfortable with
ksh than with
sh. It is a compatible shell, but offers things we take for granted today. For example,
ksh provided command line editing, coroutines, and new control structures like
select. It also borrowed ideas from the C shell such as history, functions, and aliases.
The only problem with
ksh is that AT&T held it pretty close to its chest for years. So even though not many people use
ksh today, the ideas in
ksh spread to other shells and are widely used today. There is a public domain version,
pdksh, if you want to try it out.
Ash and Dash
The Almquist shell, or
ash, is basically a clone of the Bourne shell written by Kenneth Almquist. It doesn’t add a lot of features, but it is very small and fast. This makes it a popular choice for tiny Linux distributions like rescue disks or embedded systems. In 1997 Herbet Xu ported
ash for use with Debian and it became
Dash — the Debian Almquist shell. If you use any of the Debian-derived distributions, you’ll probably find that
/bin/sh is a link to
Fish isn’t named after anyone — not even a TV detective. It stands for Friendly Interactive Shell. Unlike
fish doesn’t try to be compatible with the old classic shell programs. Instead, it tries to be very user friendly. For example, it automatically suggests things as you type.
A big feature of
fish is that it doesn’t implicitly create subshells. Consider this (contrived) example:
SUCCESS=0; cat /etc/passwd | if grep ^kirk: ; then SUCCESS=1; fi
Change “kirk” out for a user in your passwd file and try this under
bash. Then print out
$SUCCESS and you will see it stays zero no matter what. The reason is the part of the command to the right of the pipe character spawned a new shell. You set the variable in that shell, which then exits and the shell you started in still has
SUCCESS as zero. With fish, this doesn’t happen.
If you were setting up Linux for a new user,
fish might be a good choice for their default shell. For most power users, though, they’ll want to stick to something more conventional. If you do want to learn more, check out the video, below.
The Z shell is newer, dating from 1990. This may be the most popular shell outside of
bash on this list. One of the biggest reasons is that it has a plugin architecture that allows for lots of customization including themes and very sophisticated command line completion. You can edit multiline commands easily. Some plugins even provide things like an FTP client.
Many of the things you get out of the box with
zsh can be added to
bash, but it would be a lot of work. If you start
sh, it pretends to be
sh — a lot of advanced shells do that.
Because of the plugin architecture, there’s something like an app store for
zsh called “Oh My ZSH.” If you browse through it, you’ll probably be tempted to try
zsh. If you ask a seasoned Linux user — at least in the year 2020 — what shell they use, and they don’t answer
bash, they’ll probably answer
zsh. If you have an hour and a half to kill, you might enjoy the video below.
And There’s More
There are probably more shells, but ultimately it is a matter of personal preference. One we are watching is Nu shell. It has some interesting ideas about extending the idea of a pipe and stream in Linux. I haven’t tried it yet, but as it becomes more stable, I might. If you are an
emacs fan, there is
eshell — something I’ll talk about in a future post.
Wikipedia has a good comparison matrix of shells if you are curious. Personally? I use
bash, but I am always tempted to learn
zsh better. I’ve used all of these at some point except
fish. How about you? Leave a comment with your favorite shell, especially if it isn’t on this list.