Thursday, January 18, 2018

The shell

What is a shell?

When I was looking for an appropriate explanation on the concept of a shell, it gave me more trouble than I expected. 

All kinds of definitions are available, ranging from the simple comparison that "the shell is the
steering wheel of the car", to the vague definition in the Bash manual which says that "bash is an
sh-compatible command language interpreter," or an even more obscure expression, "a shell manages the interaction between the system and its users". 

A shell is much more than that.

A shell can best be compared with a way of talking to the computer, a language. Most users do know that other language, the point-and-click language of the desktop. But in that language the computer is leading the conversation, while the user has the passive role of picking tasks from the ones presented. 

It is very difficult for a programmer to include all options and possible uses of a command in the GUI-format. 

Thus, GUIs are almost always less capable than the command or commands that form the backend.
The shell, on the other hand, is an advanced way of communicating with the system, because it allows for two-way conversation and taking initiative. 

Both partners in the communication are equal, so new ideas canbe tested. The shell allows the user to handle a system in a very flexible way. An additional asset is that the shell allows for task automation.

Shell types:

Just like people know different languages and dialects, the computer knows different shell types:

sh or Bourne Shell: the original shell still used on UNIX systems and in UNIX related environments.This is the basic shell, a small program with few features. When in POSIX-compatible mode, bash will emulate this shell.


bash or Bourne Again SHell: the standard GNU shell, intuitive and flexible. Probably most advisable for beginning users while being at the same time a powerful tool for the advanced and professional user. 

On Linux, bash is the standard shell for common users. This shell is a so called superset of the Bourne shell, a set of add-ons and plug-ins. This means that the Bourne Again SHell is compatible with the Bourne shell: commands that work in sh, also work in bash. However, the reverse is not always the case. All examples and exercises in this book use bash.


csh or C Shell: the syntax of this shell resembles that of the C programming language. Sometimes asked for by programmers.


 tcsh or Turbo C Shell: a superset of the common C Shell, enhancing user-friendliness and speed.


ksh or the Korn shell: sometimes appreciated by people with a UNIX background. A superset of the Bourne shell; with standard configuration a nightmare for beginning users.


The file /etc/shells gives an overview of known shells on a Linux system:

manish:~> cat /etc/shells
/bin/bash
/bin/sh
/bin/tcsh
/bin/csh

Note that /bin/sh is usually a link to Bash, which will execute in Bourne shell compatible mode when called on this way.

Your default shell is set in the /etc/passwd file, like this line for user manish:
manish:L2NOfqdlPrHwE:504:504:manish rip:/home/manish:/bin/bash

To switch from one shell to another, just enter the name of the new shell in the active terminal. The system finds the directory where the name occurs using the PATH settings, and since a shell is an executable file (program), the current shell activates it and it gets executed. A new prompt is usually shown, because each shell has its typical appearance:

manish:~> tcsh
[manish@localhost ~]$

 Which shell am I using?


If you don't know which shell you are using, either check the line for your account in /etc/passwd or type the command.

 echo $SHELL

No comments:

Post a Comment

Configure NFS Client

This example is based on the environment below. +----------------------+           |           +----------------------+ | [...