-
The shell is responsible for reading commands/applications provided by the user.
-
The shell will check whether the command is valid and properly used. If everything is correct, the shell interprets (converts) that command into a form understandable by the kernel. The interpreted command will then be handed over to the kernel.
-
The kernel is responsible for executing the command with the help of hardware.
The shell acts as an interface between the user and the kernel.
Together, the shell and kernel form the operating system.
There are several types of shells available:
- Developed by Stephen Bourne.
- This was the first shell developed for UNIX.
- We can access this shell using the
shcommand.
- BASH stands for Bourne Again Shell.
- It is an advanced version of the Bourne Shell.
- This is the default shell for most Linux distributions.
- We can access this shell using the
bashcommand.
- Developed by David Korn.
- Mostly used in the IBM AIX operating system.
- We can access this shell using the
kshcommand.
- Developed by Bill Joy.
- "C" refers to California University.
- It is also available by default with UNIX.
- We can access this shell using the
cshcommand.
- "T" stands for Terminal.
- It is an advanced version of the C Shell.
- This is the most commonly used shell in HP UNIX.
- We can access this shell using the
tcshcommand.
- Developed by Paul.
- We can access this shell using the
zshcommand.
Note: The most commonly used shell in Linux environments is BASH. It is more powerful than the other shells.
You can check the default shell using the following commands:
$ echo $0
bash
$ echo $SHELL
/bin/bashYou can also check the default shell information inside the /etc/passwd file:
$ cat /etc/passwd
durgasoft:x:1000:1000:durgasoft,,,:/home/durgasoft:/bin/bashThe /etc/shells file contains information about all available shells:
$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dashBased on your requirements, you can switch from one shell to another.
durgasoft@durgasoft:~/Desktop$ sh
$ echo $0
sh
$ exit
durgasoft@durgasoft:~/Desktop$ echo $0
bash
durgasoft@durgasoft:~/Desktop$ rbash
durgasoft@durgasoft:~/Desktop$ echo $0
rbash
durgasoft@durgasoft:~/Desktop$ exit
exit
durgasoft@durgasoft:~/Desktop$ dash
$ echo $0
dash
$ exit┌───────────┐
│ User │
│(Commands) │
└───────────┘
│
v
┌───────────┐
│ Shell │
│ (bash, sh,│
│ csh, zsh)│
└───────────┘
│
v
┌───────────┐
│ Kernel │
│ (System │
│ Calls & │
│ Hardware)│
└───────────┘
│
v
┌───────────┐
│ Hardware │
│ (CPU, │
│ Memory, │
│ I/O) │
└───────────┘
akshay@myubuntu:~/Documents/Linux$ cd Shell\ Scripting/
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ gedit test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ gedit test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ gedit test2.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ ls -l test.sh
-rw-rw-r-- 1 akshay akshay 45 Nov 20 19:27 test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ chmod u+x test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ ls -l test.sh
-rwxrw-r-- 1 akshay akshay 45 Nov 20 19:27 test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ ./test.sh
welcome to shell scripting
Wed Nov 20 07:32:21 PM IST 2024
/home/akshay/Documents/Linux/Shell Scripting
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ ls -l test2.sh
-rw-rw-r-- 1 akshay akshay 44 Nov 20 19:28 test2.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ chmod u+x test2.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ ./test2.sh
Wed Nov 20 07:32:45 PM IST 2024
Wed Nov 20 07:32:45 PM IST 2024
Welcome to shell scripting
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ cal
November 2024
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ gedit test.sh
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ sh ./test.sh
welcome to shell scripting
Wed Nov 20 07:34:17 PM IST 2024
/home/akshay/Documents/Linux/Shell Scripting
November 2024
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ bash ./test.sh
welcome to shell scripting
Wed Nov 20 07:37:35 PM IST 2024
/home/akshay/Documents/Linux/Shell Scripting
November 2024
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
akshay@myubuntu:~/Documents/Linux/Shell Scripting$ bash ./test2.sh
Wed Nov 20 07:37:41 PM IST 2024
Wed Nov 20 07:37:41 PM IST 2024
Welcome to shell scripting