Official website for Linux User & Developer
FOLLOW US ON:
Aug
13

Shell scripting for system administrators: the basics

by Swayam Prakasha

For system administrators shell scripting can be a very useful way to drastically improve workflow. Join Swayam Prakasha to find out how you can employ some fundemental tips and techniques to make your life easier…

This article originally appeared in issue 90 of Linux User & Developer magazine.Shell scripting for system administrators: the basics Subscribe and save more than 30% and receive our exclusive money back guarantee – click here to find out more.

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:

# cat /etc/shells

And on our system, the following is the output of the above command:

/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/ksh
[root@localhost ~]#

If you are interested in knowing your current shell type, then go for this command:

# echo $SHELL

On our system, we have executed the above command like this:

[root@localhost ~]# echo $SHELL
/bin/bash

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 follow us
Pages: 1 2 3 4 5 6
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.