0% found this document useful (0 votes)
3 views26 pages

Introduction of Shell Scripting[1]

The document provides an introduction to shell scripting, explaining the roles of the kernel, shell, and terminal in Linux systems. It discusses various types of shells, including BASH, C Shell, and Korn Shell, and highlights the purpose and advantages of shell scripting for automating tasks. Additionally, it covers the basic commands used in shell scripting and outlines its elements, advantages, and disadvantages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views26 pages

Introduction of Shell Scripting[1]

The document provides an introduction to shell scripting, explaining the roles of the kernel, shell, and terminal in Linux systems. It discusses various types of shells, including BASH, C Shell, and Korn Shell, and highlights the purpose and advantages of shell scripting for automating tasks. Additionally, it covers the basic commands used in shell scripting and outlines its elements, advantages, and disadvantages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Introduction Of

Shell Scripting

DUGGIRALA SUSHANTH
23B81A05J3
CSE-C
Introduction
• If you are using any popular operating system, you are indirectly interacting with shell.
• If you are running Ubuntu, Linux Mint or any other Linux distribution, you are interacting to
shell every time you use the terminal.
• Let's discuss about Linux shells and shell scripting so before understanding shell scripting we
must get familiar with following terminologies

• Kernel
• Shell
• Terminal
KERNEL
• What is Kernel?

• The kernel is a computer program that is the core of a computer's operating system, with
complete control over everything in the system.

• It manages following resources of the Linux system

• File management
• Process management
• I/O management
• Memory management
• Device management etc.
Shell
• A shell is special user program which provides an interface to the user to use the operating
system services.

• Shell accepts human readable commands from user and converts them into something which
the kernel can understand.
• It is a command language interpreter that executes commands read from input devices such
as keyboards or from files.

• The shell gets started w hen the user logs in or start the terminal.

• Shell is broadly classified into two categories

• Command Line Shell


• Graphical shell
• Shell can be accessed by user using a command line interface.
• A special program called Terminal in Linux/macOS, or Command Prompt in Windows OS is
provided to type in the human readable commands such as "cat", "Is" etc. and then it is being
execute.

• The result is then displayed on the terminal to the user.

• A terminal in Ubuntu OS 16.4 system looks like this


• Graphical Shells
• Graphical shells provide means for manipulating programs based on graphical user
interface (GUI), by allowing for operations.
• Such as opening, closing, moving and resizing windows, as well as switching focus between
windows.

• Window OS or Ubuntu OS can be considered as good example which provide GUIto the user
for interacting with program. User doesn’t need to type in command for every action .
• A typical GUI in Ubuntu system
Types of Shells
• There are several shells that available for Linux systems like the following few

• BASH (Bourne Again Shell)


• CSH (C Shell)
• KSH (Korn Shell)
BASH

• It is most widely used shell in Linux


systems.
• It is used as default login shell in Linux
systems and in macOS.
• It can also be installed on Windows OS.
C Shell

• The C shell's syntax and


usage are very similar to the
C programming language.
Korn Shell

• The Korn Shell also was the base for the POSIX
Shell standard specifications etc.
• Each shell does the same job but understand
different commands and provide different built in
functions
Shell Scripting

• Usually shells are interactive that mean, they accept command as input from users and execute
them.

• However, some time we want to execute a bunch of commands routinely, so we have type in all
commands each time in terminal.
• As shell can also take commands as input from files, we
can write these commands in a file and can execute
them in shell to avoid this repetitive work.
• These files are called Shell Scripts or Shell Programs.
Shell scripts are like the batch file in MS-DOS.
• Each shell script is saved with .sh file extension like-
myscript.sh
• A shell script has a syntax just like any other
programming language.
• If you have any prior experience with any programming
language like Python, C,C++ etc. it would be very easy
to get started with it.
• Why do we need shell scripts ?

• There are many reasons to write shell scripts

• To avoid repetitive work and automation.


• System admins use shell scripting for routine
backups.
• System monitoring.
• Adding new functionality to the shell etc.
• Advantages of shell scripts :

• The command and syntax are the same as those directly entered in command line, so
programmer do not need to switch to entirely different syntax.

• Writing shell scripts are much quicker.

• Quick start.

• Interactive debugging etc.


• Disadvantages of shell scripts :

• Prone to costly errors, a single mistake can change the command which might be harmful.

• Slow execution speed.

• Design flaws within the language syntax or implementation.

• Not well suited for large and complex task.

• Provide minimal data structure unlike other scripting languages. etc


• A shell script comprises following
elements

• Shell Keywords - if, else, break etc.

• Shell commands - cd, Is, echo, pwd, touch


etc.

• Functions

• Control flow – if, then, else, case and shell


loops etc.
• Command in Shell Scripting :

• Ls - The Is command : The list command


function in the Linux terminal to show all of the
major directories filed under a given file system.
• Cd - The cd command : Change directory will
allow the user to change between file
directories.
• Mv - The mv command : Move allow a user to
move a file to another folder.
• Mkdir - The mkdir command : Make directory
command allows the user to make a new
directory.
• Man - The man command : The manual
command is used to show the manual of
the inputted command.
• Touch - The touch command to make file in
the directory.
• Rm - The rm command : The rmdir to
remove the file and directory in the Linux
OS.
• Clear - The clear command : The clear
command does exactly what it say clear. It
clear all readout and information from the
screen.
ls, cd, pwd commands

rm command
● Echo command
● If command

● Else command
● Then command
● Break command ● Case command
Thank
You!

You might also like