Different type of shells in Unix or Linux?

A  shell is a user program that allows the user to specify operations in a certain sequence.

As we discussed in the last post about what is the shell in UNIX or  Linux. Now we will discuss about type of shells in UNIX or Linux.

Introduction

different type of shells in Linux / UNIX

If all UNIX or Linux shell available on your system then you can switch between different shells.

Type of shells in Unix or Linux

Bourne Shell (sh)

Bourne Shell is the original Unix/ shell developed at AT&T by Stephen Bourne. Bourne shell also named as (sh) programming name. It used the symbol $. Bourne shell’s family is bourne, Korn shells, bash and zsh .

Korn shell (KSH) 

Korn shell is the Unix shell developed by David Korn of Bell labs. Is considered as the family member of the Bourne shell as it uses the $ symbol of Bourne shell. It is also named as Ksh programmatically and is the most widely used shell.

Bourne Again Shell (bash)

It is the free version of Bourne shell and comes with all UNIX/Linux systems as free with some additional features like command-line editing. Its program name is bash. It can read commands from a file called scripts.

Like all Unix shells it supports the following:

  • File name wildcarding
  • Piping
  • Hear documents
  • Command execution
  • Variables and control structures for condition testing and iteration

C Shell (sh) 

C shell is the UNIX shell created by Bill joy at California university as an alternative to Bourne shell – Unix original shell. C shell along with Bourne and Korn is there most popular and commonly used shells. csh is the program name for C shell.

Tab C Shell (tcsh) 

It is the family member of  C shell with additional features like enhanced history substitution to reuse commands, spelling correction and word completion.

Hello World Example

Create a file first.sh

#! /bin/sh // This line tells Unix that the file to be executed by /bin/sh.
echo Hello World

Now run –

./first.sh

The output will be –  Hello World

Arithmetic operators

+ (Addition)                    Adds values on either side of the operator
– (Subtraction)               Subtracts right-hand operand from the left-hand operand
* (Multiplication)          Multiplies values on either side of the operator
/ (Division)                     Divides left-hand operand by right-hand operand
% (Modulus)                  Divides left-hand operand by right-hand operand and returns the remainder
= (Assignment)             Assigns right operand in the left operand
== (Equality)                 Compares two numbers, if both are same then returns true.
!= (Not Equality)          Compares two numbers, if both are different then returns true.

#!/bin/sh

a=5
b=10

val=`expr $a + $b`
echo "a + b : $val"

val=`expr $a - $b`
echo "a - b : $val"

val=`expr $a \* $b`
echo "a * b : $val"

Working with VI editor – VI is the main editor to work on Unix systems. There is 3 main command mode on vi editors.

Command Mode – Keys works as a command like an insert, delete, moving to new line etc. We can not edit or type in command mode.

Insert Mode – To write anything in the script, press I or A for insert mode.

Execution Mode – This mode is used to execute that we have done. Like to save changes, first press escape key then types colon and wq.

Vi editor commands

:w -Save the contents of the file.

:q – To quit from vi editors.

:q! – Quit from vi editors by discarding any changes.

:wq -Save the file and quit from the vi editor.

Hope this  tutorial will help to find out, type of shells in Unix.

Please correct me, if anything found wrong here. Please comment also for any additional shell type in UNIX.

7 Comments

Leave a Reply