The Unix shell; the power of text-driven commands. Simply out of this world.
You can do anything with it; literally (Okay okay, you can't cook pancakes). From getting a list of last modified files, viewing files without opening them with our friends
more or even
less.Oh and by the way, less is more.
For those in a slight mess of things, or those seeking to find just how deep this rabbit hole goes, this is definitely for you. There are different types of shells in this beautiful text-driven command world and as a heads up, I'll list a couple of them here.
Let us get into each of these to find out what they involve.
Hush for the godfather of them all; the template, the first of its kind, the one and only
sh; the Borne Shell,named after its creator, Borne. This is the first shell to get into the Unix world. Its path?
/bin/sh. Its the boilerplate that allows the listing of directories, the file management navigation and most of the things you are aware of now if using a shell. Is this still used? Yes, absolutely. Despite its age and limited functionalities in some ways,
sh is still being used and as such many of the newer shells strive to be compatible with it, seeing as every Unix distro I have seen so far has it pre-installed. This is very common and is known to bring some confusion as to the 'it's not working' problem with Bash whose scripts are sometimes run with
$ sh some_random_script. by accident when instead it should be
$ bash some_random_script.
So, yes. As the godfather, it earns the right to be valid to this date and will still send satellites to Mars.
The lost sheep: the
csh. It's very similar to the C programming language. Hence the prefix -C. Coming in complete with tab completion. To show you just what this means, try getting into the
sh shell and head over to your home directory. Something simple, perhaps getting to your documents(or any other folder name) with tab completion.
thegreencodes@thegreencodes:~$ sh $ cd Doc #hit tab key
Nothing happens. The equivalent of being thrown deep into the deep-end.
Despite this bonus point against sh, csh has lots of bugs, left for the end-user to sort out, and hence hardly used for scripting.
I doubt you use it even on your day to day use, but if you do, take a look at reasons why not to . The conversation between the Novice and expert cracks me up every time.
Finally, an improvement of the Csh shell. You'll still need a little background with C but you would have far much less struggle as you normally would with csh. The support for this, however, is limited in comparison to the Bourn Again Shell, as is obvious with the default shell for most Linux distributions. So your question on StackOverflow might not get the traffic you might need.
Yes, that's right. As in burnt wood ashes. It's just Another Shell. Get it? Ash.
Hold your horses one minute, I'm just messing with you. It's the Almquist shell sometimes confusingly so-called
sh for short. (Remember this is a fork).
With opensource, a fork of the popular Bourne shell was made and called the Ash. In Debian based systems, this has been implemented as
dash so its a
/bin/dash directory. As expected, in most distributions based on ubuntu,
/bin/sh is just in the end a link to
/bin/dash, so you will not actually be using
Unlike its counterpart parent, this is simple and light. To invoke it, go to your terminal and simply type
thegreencodes@thegreencodes:~$ sh $
Just like that! You'll see the little dollar sign replacing your usual prompt.
Because of its rather small size, it's used in systems that do not use a lot of resources. For instance, if you have a rooted smartphone and simply love the terminal too much to let go, so much so you had Busybox installed, then there you have it; Ash. Simple, precise and light.
This, however, comes with the disadvantage of not having all the nips and tricks up its sleeve. For instance, no completion of commands, or a progress bar to show how far a process is on before it completes (Say you are installing a program). Consider it a portable shell.
Corn? I mean what? No.. its Korn.
See, David Korn(creator of Korn), went into the lab at one point in 1986 and came out with the best of csh. What makes it stand out is the use of coroutines, regular expressions, speed, command-line editing(using vi mode or emacs style right from the prompt) and debugging.
You might need to install it on your system. More information can be found from their official site.
You got it right, the Bourne Shell,
sh came back bigger and better. Just head up and take a look at all the advantages of the previous shells, then bring them here. Of course, don't come along with the pains to the party.
This is the most common of shells, beginning every script with the
#! /bin/bash. From the extensive support as you can tell with this graph in comparison to tcsh, to the flexibility, this will be your best choice of the so far mentioned.
The source code to this can be found here just in case you need to manually enter the details for comparison. Rob made a beautiful repo.
Then I stumbled upon
zsh, and things got real. I'll place it up front, that this is, in my opinion, the best of them. True to its name, it holds a much similar functionality to the bash shell but with way lots more.
Now we both know that you can create
bash scripts, add them to your profile and call a single command to do who knows what. For example:
#say a script that makes child processes do several things in the #background thegreencodes@thegreencodes:~$ make_babies
This comes with one disadvantage; load time. You see, because your script is external, it needs to be loaded first. So you'll append something like this to your
If you need the slight kick, that slight jolt when executing, you would rather have a shell that already knows what you are saying. As an example, it supports floating points which, you know what, bash does not.
A simple calculation with the bash calculator :
3.5/2 1 # zsh calculator 3.5/2 1.75
Now combine zsh with oh my zsh and you get cranberry pie. You know how you get the terminal with a prompt showing you whether you are in a git repo without having to write the all well known
git status? Something like:
~ RandomRepository git:(master)
Yeah.. that little guy that makes it much more relaxing. Coupled with its 101 plugins, you are bound to get something worthwhile suited just to your needs. As an example; the
autojump plugin that lets you get to a directory without typing out its full or relative path. Just key in its directory name and walla! I'll leave this bookmark here for you to try it out yourself.
Before we close this for loop of shells, I should mention we also have fish, and (I know.I know I should not make a fish joke) do not get me started on the autocompletion. This is something I have not seen in the other shells. Out of the box. I would place zsh and fish at loggerheads but seeing as I am yet to dive in head to toe with it, I'll be back once my finger muscle memory works better.
In the end, with all these shells in play, the choice comes down to your preference and set up. What makes you feel productive? What are you comfortable using on the fly? This is the million-dollar question even I cannot answer. Well, fam, it's been fun and as I promised, I'm going fishing. Till next time: TheGreenCodes
Set up a twitter account for all the regular post updates and out of the oven content. You should check TheGreenCodes account out. As always, here to learn, share and grow.