Which Linux Shell Is Best? 5 Common Shells Compared

Tips

Happy using the bash shell in Linux? Or would you prefer to try out an alternative? There’s tsch, fish, KornShell, and Z Shell to choose from. But which of these popular Linux shells is best?

What Is a Linux Shell?

Usually, when you write an application, it’s done in a high-level language that humans can understand. Examples of these are C#, Java, C++, etc. Believe it or not, your computer sees everything as 1s as 0s or, as commonly known, binary or machine code







What Is Binary? [Technology Explained]

Given that binary is so absolutely fundamental to the existence of computers, it seems odd that we’ve never tackled the topic before – so today I’d thought I’d give a brief overview of what binary…
Read More

.

A compiler will then translate the high-level language into a binary file like an executable. This binary file is what you execute to launch said application.

Now, this is a very high-level view of what happens; just remember, your computer needs a translation layer. This sits between what you’re telling it to do and how it can understand that.

A shell is what’s known as an interpreter. Similar to a compiler, an interpreter translates the human code into machine code. One of the differences is that an interpreter does this one statement at a time. Meanwhile, a compiler scans the entire program and translates it all into machine code.

The shell, then, is an interface for you to interact with your operating system (OS). As you type commands into the shell, it’s responsible for interpreting those commands and making the magic happen. Operations like copying files, piping, listing files are all within a shell’s remit.

Several Linux shells are available. To find out all the shells that are available on your system, open the terminal and type:

cat /etc/shells

To find out what shell you’re currently using type:

echo $0

What is the best Linux shell

But are you using the best Linux shell? Let’s look at what is available.

1. Bash

This is by a mile the most popular shell among Linux users. It’s hard to even think about shells without the Bourne-Again Shell (bash) being a part of the equation. Many Linux distributions ship with bash as the default shell because bash is the default GNU shell. Released in 1989, it also boasts a few decades of healthy development behind it.

Bash’s predecessor is The Bourne Shell (sh) which is one of the original Unix shells. One attractive feature to sh programmers was that they could port their scripts directly to bash entirely unchanged. Bash also offers several enhancements to its predecessor:

  • Command completion
  • Command history

Often online documentation will assume you are using bash. However, it is not without its shortcomings—as anyone who has ever written a bash script can attest to! It’s not that you can’t do something, it’s that it’s not always particularly elegant to read and write.

2. KornShell

Is KornShell the best Linux shell?

Commonly known as ksh, KornShell is a popular alternative Linux shell that originated out of Bell Labs in the 1980s. There aren’t many differences between bash and ksh, but each has minor advantages over the other. Ksh, for example, has the cd old new command. If you were in the directory /Downloads/foo/bar/one/foobar and you needed to get to /Downloads/foo/bar/two/foobar you just need to enter:

cd one two

Veterans of ksh will advocate it’s superiority by mentioning its scripting benefits. These include:

  • Better loop syntax
  • Natural ways to repeat commands
  • Associative arrays

Unlike bash, it’s tough to find help for ksh online. If you want to give ksh a try you enter:

sudo apt install ksh

ksh

3. Tcsh

Tsch shell on Linux

Tcsh can trace its roots back to the early days of Unix. It’s an improved version of the C shell (csh) and features:

  • Programmable command-line completion
  • Command-line editing
  • Adding arguments to aliases
  • Easy command history access

You can run any command by typing !n replacing n with its corresponding number in the displayed history. History tab completion in tcsh works by typing:

!a<TAB>

This expands to the last command that started with the letter “a”. Comparatively, in bash, you would have to type !a:p to first see the command, followed by !! to execute it.

To give tcsh a try, type:

sudo apt install tcsh

tcsh

Tcsh is the default shell for BSD based systems like FreeBSD. The big selling point for tcsh is its scripting language, useful to anyone who is primarily programming in C







Why C Programming Is Still Worth Learning

C is not a dead language. In fact, IEEE Spectrum magazine ranked it as the No. 2 top language in 2017. Here are five reasons why.
Read More

. This makes tcsh useful for prototyping small C programs without getting confused over things like which brackets you’re using. This problem tends to happen if you’re continually switching between C programming and shell scripting.

4. Fish

Use the fish shell on Linux

Among all the seriousness of Linux, the team at fish have embedded a sense of humor in their project. On their website, the tongue-in-cheek title reads “Finally, a command line shell for the 90s” although fish (“friendly interactive shell”) was developed in 2005. Beyond the touted “Glorious VGA Color,” are some enhancements over other shells:

This feature adds the syntax from the man page of newly installed software to your auto-complete suggestions. If you’d like to get more familiar with the command line, fish can be a great place to start.

To sample what fish is about, type:

sudo apt install fish

fish

5. Z Shell

Z Shell on Linux

Many would consider this to be leaving the best shell for last, which would be completely understandable. Zsh has similarities to bash and ksh and incorporates many of the features found in them as well as tcsh. Zsh features:

  • Navigable autocompletion list
  • Superior spelling correction
  • Command line completion
  • History shared across terminals
  • Globbing (wildcard characters for filenames)

Globbing in zsh is very useful. Typing:

vim /u/l/b/a<TAB>

Would open the file:

/usr/local/bin/autoupdate.sh

Zsh can take a while to configure on first use if you don’t go with the default config. To give it a try, enter:

sudo apt install zsh

zsh

Which Linux Shell Is Best for Me?

The fact that these options are available is brilliant. Each is a glimpse into computing history, where programmers decided they wanted to make things their own way.

The substantial differences between these shells can be found in the scripting syntax. Each shell has a particular set of nuances that separate them from each other. As it stands, bash dominates in terms of market share, which makes finding help much simpler. Bash is simply the best all-rounder, meeting the needs of all but the most advanced users.

When you’ve settled on a Linux shell, be sure you’re familiar with the basics of shell scripting







What Is Shell Scripting and Why You Should Use It

In addition to being able to accept and execute commands interactively, the shell can also execute commands stored in a file. This is known as shell scripting. Here we cover the basics of shell scripting.
Read More

.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Products You May Like

Leave a Reply

Your email address will not be published. Required fields are marked *