Shell in Unix

A shell is software that provides an interface for users of an operating system which provides access to the services of a kernel. — Wikipedia

I share the note of shell training here. In the training, we’ve used Bash for the most of the time.

I picked up two images from Internet, it describes how does shell works.

shell1

shell2

There are two families of shell:
1. Bourne shell(sh) 1978, Korn shell (ksh) 1983, Bourne again shell (bash) 1989, Z shell (zsh)
2. C shell (csh), Turbo C shell (tcsh) (Tenex Tops shell/Toronto shell)

Prompt(after that we type our commands):

shell user

Function of a shell

shell function

In the left diagram, we could see the function of shell. Each time, shell receives a command, it will do like in the diagram.

The command internal is already exist when your system is installed.

The command external is associated with a file executable. This file contains a program and it is identified by the system. When the file is executed, system will create a process and execute the program.

The file executable has two types:

1. Program (also called binary file), can be execute by system directly, not readable for a human being.

2. Script (text file), executed with the help of an interpreter(shell, perl and etc), readable for us.

PS. It is not long ago, a college told me, whatever the other programming languages(Java, PHP …) can do, shell can do it or even better. More faster, more efficient, does not consume too much memory. But during the training, I asked the professor this question, “Is shell better, I mean faster, than the other languages?”, he told me, shell is really a good language, he is more closer to the system, but he is also a programming language, each time he executes a command, he will create a new process, so he is not exact the fastest.

To be continued.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s