If you’re just joining us, this is the forth article is a series of introductory articles to the command line. We are continuing from the article “Command Line Terminals”.
We’ve gone over a lot to get here. Now we’re going to look at the heart of it all, the command line shell. The shell is the work horse of it all. It’s an interactive terminal/text based program that lets you type in commands instructing the computer what to do. On many Unix based systems there isn’t a single shell but usually a few to choose from. On Linux systems,
bash is usually the default one, the one we’ll be focusing on. Other shells include zsh, tcsh, fish and korn.
Shells were originally created with the invention of Unix all the way back to the early 1970’s. Over the years, these shells have continually evolved with the technology and the needs of the users.
The first and most obvious feature is the command prompt. Although it’s a very simple interface for entering commands, it can be customized with a lot of advanced features to make working from it very productive.
An important feature is environment variables. These variables are used for customization, configuration and processing information. For example the PATH environment variable contains a list of directory paths the shell uses to find the commands from. Also the prompt, language, default editor and default pager are come of the settings found in the environment variables.
Each shell also have several builtin commands that add a lot of functionality and further configurable options. This includes multitasking and job management as well as IO redirection and piping.
Although the command prompt looks very simple most shells include a lot of advanced editing features. This includes cut, copy, paste, inserting, deleting and auto completion. Auto completion makes the TAB key absolutely magical.
Every command is saved in a history file that is searchable and commands can be recalled in many ways. The history can be used interactively and through builtin commands its behaviour tailored.
Commands can get quite complicated and hard to remember. To make this situation easier, commands can be saved into a text file known as a shell script. A shell script can be run as a command itself and is an incredibly powerful way to automate tasks.
Putting the Shell to Work
The entire Unix operating system is based on the idea of it being a toolbox. Where a program does one thing, does is well and works with other programs. This toolbox approach doesn’t make any assumption on how the technology will be used but rather offers a great amount of flexibility with how it can be used. The simplicity of the text interface makes it very light weight and is one of the best compromises between the computer and the user. This interface allows programs be simple and lean and allows the user to truly harness the capabilities of the computer.
Now that we have all the pieces, with in the next articles, we can start looking at putting all of this to work.