Shell Scripting part-1 | What is Shell and Types of Shells

Shell Scripting part-1 | What is Shell and Types of Shells

What is Shell?

linux-0203-1919.png

1) Shell is responsible to read commands/applications provided by user.

2) Shell will check whether command is valid or not and whether it is properly used or not. If everything is proper then shell interprets (converts) that command into kernel understandable form. That interpreted command will be handover to kernel.

3) Kernel is responsible to execute that command with the help of hardware.Shell acts as interface between user and kernel. shell+kernel is nothing but operating system.

Types of Shells: There are multiple types of shells are available.

1) Bourne Shell:

It is developed by Stephen Bourne.

This is the first shell which is developed for UNIX.

 By using sh command we can access this shell.

2) BASH Shell:

 BASH -> Bourne Again SHell.

 It is advanced version of Bourne Shell.

 This is the default shell for most of the linux flavours.

 By using bsh command we can access this shell.

3) Korn Shell:

 It is developed by David Korn.

 Mostly this shell used in IBM AIX operating system.

 By using ksh command, we can access this shell. 4) CShell:

 Developed by Bill Joy.

 C meant for California University.

 It is also by default available with UNIX.

 By using csh command, we can access this shell. 5) TShell:

 T means Terminal.

 It is the advanced version of CShell.

 This is the most commonly used shell in HP UNIX.

 By using tcsh command, we can access this shell. 6) Z Shell:

 Developed by Paul.

 By using zsh command we can access this shell.

Note: The most commonly used shell in linux environment is BASH. It is more powerful than remaining shells. How to Check Default Shell in our System?

$ echo $0
bash
$ echo $SHELL
/bin/bash

How to check all available Shells in our System?

/etc/shells file contains all available shells information.

$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash

How to Switch to other Shells?

Based on our requirement we can switch from one shell to another shell

abarik@abhijit-virtualbox:~$ sh
$ echo $0
sh
$ exit
abarik@abhijit-virtualbox:~$ echo $0
/bin/bash
abarik@abhijit-virtualbox:~$ rbash
abarik@abhijit-virtualbox:~$ echo $0
rbash
abarik@abhijit-virtualbox:~$ exit
exit
abarik@abhijit-virtualbox:~$ dash
$ echo $0
dash
$ exit