The Best Linux Shells
The shell is the command interpreter in an operating system such as Unix or GNU/Linux; it is a program that run other programs. It provides a computer user with an interface to the Unix/GNU Linux system so that the user can run different commands, utilities, or tools with some input arguments.
The shell is used in the background by various system services. Linux distributions include many functions written as shell scripts. These scripts are commands and other advanced shell scripting functions run through the shell environment.
The very first shell environment was the Thompson Shell, developed at Bell Labs and released in 1971. Shell environments have been building on the concept ever since, adding a variety of new features, functionality, and speed improvements.
Fish
Fish (Friendly Interactive Shell) is a nice alternative to most of the other shells. It has a consistent syntax, nice tab completion and syntax highlighting, is easy to pick up and use (especially if you don't have habits from other shells), and has excellent runtime help.
The downside is that it's erratically developed, has a small (though helpful) user base, and is very different than other shells. Backwards compatibility with shell idioms was not a priority.
In many cases this is good. A lot of the standard shells have really stupid ways of doing things, just because it's always been done that way. "do/done", "case/esac", "if/fi"? This is insanity that fish does away with.
Bash
The most common shell, by far, on Linux is bash. Unless you have a good reason to use an alternative, I'd suggest that sticking with bash, or the most commonly used shell by your project team (or that the bulk of the shell scripts you have to work with) uses.
The only other very common contender is dash, which is becoming more widely used by the Ubuntu project.
The Portable Operating System Interface for Unix, or POSIX, was another response to the hectic proprietary csh implementations. It successfully created a standard for command interpretation (among other things) and eventually mirrored a lot of the features in the KornShell. At the same time, the GNU Project was attempting to create a free, Unix-compatible operating system. The GNU Project developed a free software shell to be part of its free operating system and named it the “Bourne Again Shell”, or “bash”.
Zsh
Almost every shell you’ll encounter is Bourne-based and works similarly, including zsh.
That’s why zsh is popular. This newer shell is compatible with bash, but includes more features. The zsh shell offers built-in spelling correction, improved command-line completion, loadable modules that act as plug-ins for your shell, global aliases that allow you to alias file names or anything else on the command line instead of just commands, and more theming support. It’s like bash, but with a lot of extras, additional features, and configurable options you might appreciate if you spend a lot of time using the command line.
If you’re familiar with bash, you can switch to zsh without learning a different syntax—you’ll just gain additional features. If you’re familiar with zsh, you can switch to bash without learning a different syntax—you just won’t have access to those features.
“Oh My ZSH” is a tool that helps you more easily enable zsh plug-ins and switch between premade themes, quickly customizing your zsh shell without spending hours tweaking things.
There are other shells, too. For example, the tcsh shell is still around and is still an option. FreeBSD uses tsch as its default root shell and ash as its default interactive shell. If you use the C programming regularly, tsch might be a better fit for you. However, it’s nowhere near as commonly used as bash or zsh.
Csh
Tcsh is an enhanced C shell, it can be used as an interactive login shell and shell script command processor.
Tcsh has the following features:
- C like syntax
- Command-line editor
- Programmable word and filename completion
- Spelling correction
- Job control
Why Csh is not good?
The problem with csh is that it's terrible for scripting, as explained here. There's no real reason why you shouldn't use it as an interactive shell, but most people find it confusing having to learn two different shells and not being able to try out bits of their scripts on the command line, so it's easiest to use the same for everything.
Which Should You Choose? (and Why Zsh is Popular)
You don’t need to choose a shell. Your operating system chooses your default shell for you, and that choice is almost always bash. Sit down in front a Linux distribution—or even a Mac—and you’ll almost always have a bash shell environment. Bash has quite a few advanced features, but you probably won’t use them unless you program shell scripts.
On embedded Linux systems or BSD systems, you’ll end up with the ash shell. But ash is a Bourne-based shell and is largely compatible with bash. Any knowledge you have from using bash will transfer to using an ash or dash shell, although some advanced scripting features are not available in this lightweight shell.
Other interactive shells
The obvious candidates for an interactive shell are bash, dash, zsh and {pd,}ksh. All of these implement the posix shell standard, with some minor extensions. Pick whichever you like for interactive use. I'd tend to go with bash just because it's the standard on linux but they all have their merits and zsh in particular seems popular.
If you're writing a script that you intend to be portable, use #!/bin/sh, and make sure you use standard posix shell syntax. If it works on both bash and ksh it's probably standard. There are some old versions of unix which have a non-standard /bin/sh but I wouldn't bother with that unless you know you have to. More of a problem for portability are all the command line tools you call from your script.
Conclusion
And that's it. These are the four Linux shells that are popular and it's cool to dive into them. Chances are that you're most likely using the Bash Linux shell but if you're using any other then let us know in the comment section below.
Recent Stories
Top DiscoverSDK Experts
Compare Products
Select up to three two products to compare by clicking on the compare icon () of each product.
{{compareToolModel.Error}}
{{CommentsModel.TotalCount}} Comments
Your Comment