1 - Introduction to Shell Scripting
Posted in Linux , Programming , Shell ScriptingWhat is Linux Kernel ?
Kernel is the hart of Linux OS. It manages the resources of OS,
I/O management
Process management
Device management
File management
Memory management
Kernal decides who will use this resource, for how long and when.
The kernel acts as an intermediary between the computer hardware and various programs/application/shell.
Computer understand the binary language. It consists of 0s and 1s. In the past people used binary language to provide instruction to computers. It is difficult to read and write in machine language. So in Operating System there is a special program called "Shell" which accepts your instructions or commands in English(mostly), if you gave a valid command it passes it to kernel. Shell is not part of system kernel, but uses the system kernel to execute programs, create files etc.
Shell is a user program or it's environment provided for user interaction. Shell is an command language interpreter that executes commands read from the standard input device (keyboard) or from a file.
Several shell are available :
BASH ( Bourne-Again SHell )
Developed by : Brian Fox and Chet Ramey
Where : Free Software Foundation
Remark : Most common shell in Linux. It's Freeware shell.
CSH (C SHell)
Developed by : Bill Joy
Where : University of California (For BSD)
Remark : The C shell's syntax and usage are very similar to the C programming language.
KSH (Korn SHell)
Developed by : David Korn
Where : AT & T Bell Labs
TCSH
Developed by : See the man page. Type $ man tcsh
Remark : TCSH is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH).
To find all available shells in your system type following command
cat /etc/shells
Each shell does the same job, but each understand a different command syntax and provides different built-in functions.
In MS-DOS, Shell name is COMMAND.COM which is also used for same purpose, but it's not as powerful as our Linux Shells are!
Any of the above shell reads command from user (via Keyboard or Mouse) and tells Linux Os what users want. If we are giving commands from keyboard it is called command line interface ( Usually in-front of $ prompt, This prompt is depend upon your shell and Environment that you set or by your System Administrator, therefore you may get different prompt ).
To find your current shell type following command
echo $SHELL
Normally shells are interactive. It means shell accept command from you (via keyboard) and execute them.
Scripts are collections of commands that are stored in a file. The shell can read this file and act on the commands as if they were typed at the keyboard. Scripts help us to automate a wide range of tasks.
Typical operations performed by shell scripts include file manipulation, program execution, and printing text. Shell provides a variety of useful programming features to make your scripts truly powerful.
reference :
Linux Shell Scripting Tutorial v1.05r3
Writing Shell Scripts
If you gain some knowledge from this lesson and if you think this is useful leave a comment to encourage us. Good comments or bad comments all are important to usLets meet from a new lesson soon, have a nice day!!!
0 comments :