Which of These 5 Linux Shells Is Best?
Pinterest Stumbleupon Whatsapp
Advertisement

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 Linux shells is best?

What Is a 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] 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, but just remember, your computer needs a translation layer between what you’re telling it to do and how it can understand that.

A shell is what’s known as an interpreter. Similarly 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 as opposed to a compiler which scans the entire program and translates it as a whole into machine code.

The shell, then, is an interface for you to interact with your operating system (OS). As you type commands into your shell, the shell is responsible for interpreting those commands and making the magic happen. Operations like copying files, piping, listing files are all within a shell’s remit. It is also responsible for remembering your command history for checking what went through your head at a time of possible inebriation.

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

cat /etc/shells

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

echo $0

best linux shells find out what shell using

1. Bash

By a mile, the most popular shell amongst 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 sh scripts What Is Shell Scripting and Why You Should Use It 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 directly to bash entirely unchanged. Bash also offers several enhancements to its predecessor like command completion and command history.

Bash is a perfectly respectable shell, and often online documentation will invariably assume you are using it. However, bash is not without its shortcomings — as anyone who has ever written a bash script that spans a few lines 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. Bash is probably here to stay for the near future at least. It boasts an extensive install base and brigades of casual and professional users alike, who are already accustomed to its usage, and quirks.

2. KornShell

Commonly known as ksh, KornShell is an alternative shell that originated out of Bell Labs in the 1980s. Ksh began its life as proprietary software, being the de facto standard on commercial unices and therefore wasn’t available to Linux until 2000. 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 run:

cd one two

best linux shells korn shell
Veterans of ksh will advocate it’s superiority by mentioning its scripting benefits. These include including having a better loop syntax, more natural ways to repeat commands, and the barely used, associative arrays. For basic input bash is quite similar to ksh for advanced scripting, however, this is sure to be a different experience. Another thing to be mindful of is requesting help for ksh online. This may involve waking a grizzled advanced user from his slumber to help you. Relative to bash, which will get you a flurry of answers almost immediately!

If you want to give ksh a try you can type:

sudo apt install ksh
ksh

3. Tcsh

Tcsh can trace its roots back to the early days of Unix. It is essentially the C shell (csh) with programmable command-line completion, command-line editing, and a few other features. Tcsh is the default shell for BSD based systems like FreeBSD. The big selling point for tcsh is its scripting language, which should look very familiar to anyone who has programmed in C. Tcsh is a worthy candidate for learning if you find yourself primarily programming in C Why C Programming Is Still Worth Learning 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.

Tcsh’s scripting is adored by some and loathed by others. But it has other features as well, including adding arguments to aliases, and various defaults that might appeal to your preferences. One of its significant features includes the way auto-completion with <TAB> and history <TAB> completion work. After pulling up your history by typing history. Tcsh will display a numbered list of your previous commands, with a very convenient time stamp. 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

4. Fish

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” – fish (“friendly interactive shell”) was developed in 2005. Beyond the touted “Glorious VGA Color,” are some enhancements over other shells. Commands that have an invalid syntax will display as red, and correct syntax in blue. Additionally, there are lavish sets of tab completions like color-coded auto-complete suggestions which are based on your history.

best linux shells fish

best linux shells auto

Fish also boasts command completion based on the man pages on your machine How to Shorten Man Pages Into Readable Explanations on Linux and macOS How to Shorten Man Pages Into Readable Explanations on Linux and macOS MacOS and Linux each have a useful command, "man" which displays manual explanations for terminal commands. As they're often lengthy, why not use the tldr tool to shorten them into readable chunks? Read More . So if you’ve just installed a new program and need to get accustomed to its syntax, fish will grab the syntax from the man page and add it to your auto-complete suggestions. Neat! If you’d like to get more familiar with 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

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. Some useful features of zsh include a navigatable autocompletion list. Unlike bash which merely lists all available commands and gets you to type it manually. Globbing in zsh is inexplicably useful. Typing:

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

Automatically opens the file:

/usr/local/bin/autoupdate.sh

Spelling correction in zsh is far superior to that of bash. In a cd command bash can correct up to one character. Zsh, on the other hand, can be configured to autocorrect 10 spelling errors in one word. Zsh also nails command line histories. This is extremely useful for users who spend excessive amounts of time on the terminal. Zsh magically shares histories across terminals, making multi-terminal sessions a breeze.

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 Shell Is for Me?

The fact that these options are available is brilliant. They’re glimpses into the history of computing itself, where programmers decided they wanted to make things their own way, and eventually, set them free to the world.

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.

Which shell do you currently use? Have you tried any shell other than bash? What do you love or hate about your current shell? Share your thoughts in the comments below!

Image Credit: spaxiax/Depositphotos

Leave a Reply

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

  1. Heimen Stoffels
    November 6, 2017 at 3:51 pm

    Fish ftw! Discovered it last year and I've been using it ever since 'cause it's so much nicer looking and so much easier to use. I can't even start to describe what I love about it 'cause it has so many neat features! I think Fish is more user-friendly, esp. for newcomers (but also for long-time users like me!), it should be default on the most user-friendly distros IMHO.

    • Yusuf Limalia
      November 7, 2017 at 9:00 am

      Hi Heimen.

      You're absolutely right, Fish is just so pretty and easy to work with. I hope your comment encourages others to try it aswell

      Y
      =)

  2. dragonmouth
    November 3, 2017 at 6:19 pm

    I currently use bash. But I did not choose it, it chose me. It has been the default shell of all the distros that I have used so far.

    If I change my shell, how does that affect the applications I use? Or is it transparent?

    • Yusuf Limalia
      November 3, 2017 at 10:02 pm

      Hello there Dragonmouth =)

      I don't think it will affect your application specific commands. For example if you had git installed, I don't think it matters which shell you're using, git has a specific set of commands and only those will work.

      The biggest difference, if you change your shell will be in scripting.

      I think the best way will be to install one, get into it and just try a few of your usual commands. If you don't like it, or it isn't working out for you, typing bash or exit will get you back to your original shell.

      • dragonmouth
        November 3, 2017 at 10:28 pm

        I was thinking more of apps like Libre Office, GIMP and such.

        I have seen a lot of articles on bash scripting but very few, if any, about scripting for the other shells. I assume they are out there.

        • Yusuf Limalia
          November 4, 2017 at 5:43 am

          Good observation! The vast majority of the scripts available on the internet will be bash. And yes, the others definitely are out there. Are you considering a new shell?

        • dragonmouth
          November 4, 2017 at 9:56 pm

          I am always considering trying something new. :-)

          I have not gotten into bash and bash scripting yet. So now is a good time to change shells (maybe). I won't have much to unlearn.