Hello, everyone!
lets understand one of the most important
topics of Linux OS, Shell programming, a programming
language used to execute scripts in Linux OS.
Shell can read a list of commands as input from a file and
can execute them in a sequence to avoid repetitive work.
These files containing commands are called Shell Scripts.
or Shell Programs. Shell scripts are similar to the batch
file in MS-DOS. Each shell script is saved with .sh file
extension e.g. myscript.sh
A shell script has syntax just like any other programming
language. If you have any prior experience with any
programming language like Python, C/C++ etc., you may be
very comfortable with shell scripting.
Shell scripts are most commonly used piece of codes for
security professionals and researchers to avoid repetitive
work, perform tasks automatically such as to do routine
backups, Monitor the system and incorporating additional
features into the shell. The ethical hackers write shell
scripts to automate the complete attack and try them to
perform penetration testing also.
Let’s learn some basics of writing shell scripts. The first
thing you should know about is she- Bang. Each shell script
starts with a sign #! called as she-bang and is written at top
of the script. It passes instruction to program /bin/sh.
To run your script in a certain shell (supported by your
system), start your script with she-bang followed by the
shell name such as /bin/bash for bash shell.
A shell script is written with the following pieces.
Shell keywords such as if, else, and break
Shell commands such as cd, ls, echo, PWD, and touch
Functions and
Control flow such as If...then...else, case and shell loops
There are many advantages of using shell scripts such as
The programmer does not need to move to a different
syntax because the command and syntax are identical to
those typed directly on the command line. Similarly
Shell scripts are much faster to write than Java scripts and
anyone having some programming knowledge may Get
started quickly and It allows debugging in real time.
In the next video, you will learn about writing and executing
shell scripts.
Thank You…