Notice: Undefined index: order_next_posts in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 194

Notice: Undefined index: post_link_target in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 195

Notice: Undefined index: posts_featured_size in /nas/content/live/gadgetmag/wp-content/plugins/smart-scroll-posts/smart-scroll-posts.php on line 196

Shell scripting for system administrators: the basics

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.

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:
[sourcecode language=”bash”]# cat /etc/shells
And on our system, the following is the output of the above command:
[sourcecode language=”bash”]/bin/sh
[root@localhost ~]#
If you are interested in knowing your current shell type, then go for this command:
[sourcecode language=”bash”]# echo $SHELL
On our system, we have executed the above command like this:
[sourcecode language=”bash”][root@localhost ~]# echo $SHELL
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”]