
This article originally appeared in issue 90 of Linux User & Developer magazine.![]()
If we frequently use a sequence of commands, it goes without saying that it’s a waste of time to constantly retype them at a command prompt. Scripting is a mechanism that eliminates this need by automating the command sequence for you. Now a days, scripting has become an integral part of a system administrator’s job. Shells are used to accept commands given by the user. We usually come across different shells. The most commonly used are:
a. C shell (CSH)
b. Korn shell (KSH)
c. Bourne shell (SH)
Which shell to use is based on our requirements and we can specify it within our shell script. To find all available shells on your system, you can type the following command:
[sourcecode language=”bash”]# cat /etc/shells
[/sourcecode]
And on our system, the following is the output of the above command:
[sourcecode language=”bash”]/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
[root@localhost ~]#
[/sourcecode]
If you are interested in knowing your current shell type, then go for this command:
[sourcecode language=”bash”]# echo $SHELL
[/sourcecode]
On our system, we have executed the above command like this:
[sourcecode language=”bash”][root@localhost ~]# echo $SHELL
/bin/bash
[/sourcecode]
Let us understand some of the advantages offered by shell scripts. They can take input from a user or file and output them onto the screen. Using shell scripting, we can automate many everyday tasks and thereby save an awful lot of time.
[twitter username=”linuxusermag”]








