What is a Shell & Shell script very basic to learn for freshers
What is a shell ?
The Shell is a command line interpreter that executes commands read from the standard input device such as keyboard or from a file. In other forms, it is a user program or it is an environment provided for user interaction. We can start using the shell by opening the console(terminal). The shell is not a part of system kernel, but it uses the system to execute programs. what is a shell .
The various shells available for Linux are:
- BASH (Bourne-Again SHell) – Most common shell in Linux. It is an Opensource software
- CSH (C SHell) – The C shell’s syntax and usage are very similar to the C programming language.
- KSH (Korn SHell) – Created by David Korn at AT & T Bell Labs. The Korn Shell also was the base for the POSIX Shell standard specifications.
- TCSH – It is an enhanced but completely compatible version of the Berkeley UNIX C shell (CSH). what is a shell.
What is a shell script ?
- A shell script is series of commands stored in a plain text file.
- Shell scripts are a fundamental part of the UNIX and Linux programming environment.
- Scripts are useful for automating the processes repeatedly at the command line.
- Linux users involved with system administration and troubleshooting often work with the shell scripts.
- /etc/profile is the system-wide user login script which runs whenever a user logs into the system.
Each shell script consists of
- Shell keywords such as if..else, do..while.
- Shell commands such as pwd, test, echo, continue, type.
- Linux binary commands such as w, who, free etc..
- Text processing utilities such as grep, awk, cut.
- Functions – add frequent actions together via functions. For example, /etc/init.d/functions file contains function to be used by most or all system shell scripts in the /etc/init.d directory.
- Control flow statments such as if..then..else or shell loops to preform repeated actions.
Each script has purpose
- Specific purpose – For example, backup file system and database to NAS server.
- Act like a command – Each shell script is executed like any other command under Linux.
- Script code usability – Shell scripts can be extended from existing scripts. Also, you can use functions files to
- package frequently used tasks.
Why shell scripting?
- Shell scripts can take input from a user or file and output them to the screen.
- Whenever you find yourself doing the same task over and over again you should use shell scripting, i.e., repetitive
- Task automation.
- Creating your own power tools/utilities.
- Automating command input or entry.
- Customizing administrative tasks.
- Creating simple applications.
- Since scripts are well tested, the chances of errors are reduced while configuring services or system administration tasks such as adding new users.
- Real time usage of shell scripts where it is actively used:
- Monitoring Linux system.
- Data backup and creating snapshots.
- Dumping Oracle or MySQL database for backup.
- Creating email based alert system.
- Find out what processes are eating up our system resources.
- Find out available and free memory.
- Find out all logged in users and what they are doing.
- Find out if all necessary network services are running or not. For example if web server failed then send an alert to system administrator via a pager or an email.
- Find out all failed login attempt, if login attempt are continue repeatedly from same network IP automatically block all those IPs accessing your network/service via firewall.
- User administration as per our own security policies.
- Find out information about local or remote servers.
- Configure server such as BIND (DNS server) to add zone entries.
- Easy to use.
- Quick start, and interactive debugging.
- Time Saving.
- Sys Admin task automation. what is a shell
- Shell scripts can execute without any additional effort on nearly any modern UNIX / Linux / BSD / Mac OS X operating system as they are written an interpreted language.
- Compatibility problems between different platforms.
- Slow execution speed.
- A new process launched for almost every shell command executed.
Your Feedback will motivate us to provide the more to you………. what is a shell
Thanks for your wonderful Support and Encouragement
- Do Not Miss Interesting and Important Articles: Signin Now
- Download free PDF Books : Download Anything and Everything for Free
- Stay Connected with Us: Facebook Page | Twitt | Google Plus | LinkedIn | RSS feeds
- High Qualitfy Video Tutorials : All Videos
- Still You Have Question? : Ask Us
Click on above colored text to access appropriate page