Shell and its types in LINUX

3,548 views 21 slides May 31, 2021
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

Shell and its types in LINUX


Slide Content

SHELL AND ITS TYPES
IN LINUX
Prof. NeerajBhargava
Mrs. Shubha Chaturvedi
Department of Computer Science, School of Engineering & System Science
MDS University Ajmer, Rajasthan

Linux Shell
•Computerunderstandthelanguageof0'sand
1'scalledbinarylanguage.
•Inearlydaysofcomputing,instructionare
providedusingbinarylanguage,whichis
difficultforallofus,toreadandwrite.
•SoinO/sthereisspecialprogramcalledShell.
•Shellacceptsyourinstructionorcommandsin
Englishandtranslateitintocomputersnative
binarylanguage.

This is what Shell does for users

•It'senvironmentprovidedforuserinteraction.
•Shellisancommandlanguageinterpreter
thatexecutescommandsreadfromthe
standardinputdevice(keyboard)orfroma
file.
•Linuxmayuseoneofthefollowingmost
popularshells(InMS-DOS,Shellnameis
COMMAND.COMwhichisalsousedforsame
purpose,butit'snotaspowerfulasourLinux
Shellsare!)

Different Types of Shells
•In UNIX there are two major types of shells:
1.The Bourne shell (includes sh, ksh, and bash)
2.The C shell (includes cshand tcsh)
•IfyouareusingaBourne-typeshell,the
defaultpromptisthe$character.
•IfyouareusingaC-typeshell,thedefault
promptisthe%character.

The different types of Bourne shells as follow:
1.Bourne shell (sh)
2.Kornshell (ksh)
3.Bourne Again shell (bash)
4.POSIX shell (sh)
The different C-type shells follow:
1.C shell (csh)
2.TENEX/TOPS C shell (tcsh)

Types of Shells

•Anyoftheaboveshellreadscommandfromuser
(viaKeyboardorMouse)andtellsLinuxO/swhat
userswant.
•Ifwearegivingcommandsfromkeyboarditis
calledcommandlineinterface(Usuallyin-front
of$prompt.Thispromptisdependuponyour
shellandenvironmentthatyousetorbyyour
SystemAdministrator,thereforeyoumayget
differentprompt).
•NOTE:Tofindyourshelltypefollowing
command$echo$SHELL

The Original Bourne Shell
•TheoriginalUNIXshellwaswritteninthemid-1970s
byStephenR.BournewhilehewasatAT&TBellLabs
inNewJersey.
•TheBourneshellwasthefirstshelltoappearon
UNIXsystems,thusitisreferredtoas"theshell.“
•TheBourneshellisusuallyinstalledas/bin/shon
mostversionsofUNIX.Forthisreason,itistheshell
ofchoiceforwritingscriptstouseonseveral
differentversionsofUNIX.

Features of Bourne Shell
Inadditiontobeingacommandinterpreter,the
Bourneshellisapowerfullanguagewitha
programmingsyntaxsimilartothatoftheALGOL
language.FeaturesoftheoriginalBourneshell:
1.Processcontrol
2.Variables
3.Regularexpressions
4.FlowcontrolandLoops
5.Powerfulinputandoutputcontrols
6.Functions

Drawbacks of Bourne shell
DrawbacksoftheoriginalBourneshellisthat
itishardtouseinteractively.
1.Nofilenamecompletion
2.Nocommandhistoryorcommandediting
3.Difficultyinexecutingmultiplebackground
processesorjobs

The C Shell
•BillJoydevelopedtheCshellwhilehewasatthe
UniversityofCaliforniaatBerkeleyintheearly1980s.
•Itwasdesignedtomakeinteractiveuseoftheshell
easierforusers.
•Anotherdesigngoalwastochangethesyntaxofthe
shellfromtheBourneshell'solderALGOLstyletothe
newerCstyle.
•TheClanguagestyleoftheCshellwasintendedasan
improvementbecausetheClanguagewasfamiliarto
theprogrammersworkingonUNIXatBerkeley.
•TheideawasthatashellthatusedClanguagestyle
syntaxwouldbeeasiertowritescriptsinthanashell
thatusedtheALGOLstylesyntax.

Drawbacks of C Shell
The C shell could not be used for much more
than the most trivial scripts. Some of the
major drawbacksare :
1.Weak input and output controls
2.Lack of functions
3.Confusing syntax due to a "lazy" command
interpreter.

Features of C Shell
AlthoughtheCshelldidnotcatchonforscripts,ithasbecome
extremelypopularforinteractiveuse.Somethispopularityfollow:
1.CommandHistory.Youcanrecallcommandsyoupreviouslyexecuted
forre-execution.Youcanalsoeditthecommandbeforeitisre-
executed.
2.Aliases.Youcancreateshortmnemonicnamesforcommands.
AliasesareasimplifiedformoftheBourneshellfunctions.
3.FileNameCompletion.YoucanhavetheCshellautomatically
completeafilenamebyjusttypingafewcharactersofthefile's
name.
4.JobControls.TheCshellenablesyoutoexecutemultipleprocesses
andcontrolthemusingthejobscommand.
TheCshellisusuallyinstalledonmostsystemsas/bin/csh.
TheTENEX/TOPSCshell,tcsh,isanewerversionoftheCshell
thatenablesyoutoscrollthroughthecommandhistoryusingtheup
anddownarrowkeys.

Korn shell
•DavidKornofAT&TBellLabswrotetheKorn
shell,ksh,whichincorporatesalltheCshell's
interactivefeaturesintotheBourneshell's
syntax.
•Inrecentyears,mostvendorshavestartedto
shiptheKornshellwiththeirversionsofUNIX.
•Usuallyyouwillfinditinstalledas/bin/kshor
/usr/bin/ksh.

Features ofKorn shell
Features that the Korn shell brings to the
Bourne shell include the following:
•Command history and history substitution
•Command aliases and functions
•File name completion
•Arrays
•Built-in integer arithmetic

There are 3 major versions of kshavailable:
•The Official version (ksh) :The Official version
is available in binary format (no sources).
•The Public Domain version (pdksh):The Public
Domain version is available in both binary and
source format
•The Desktop version (dtksh) :The Desktop
version provides the capability to create and
display Graphical User Interfaces (GUIs) using
kshsyntax.

POSIX shell
•The POSIX shell is another variant of the Korn
shell.
•Currently, the only major vendor shipping the
POSIX shell is Hewlett-Packard.
•In HP-UX 11.0 (Hewlett Packard Unix), the
POSIX shell is installed as /bin/sh. The Bourne
shell is installed as /usr/old/bin/sh.

The Bourne Again Shell
•The Bourne Again shell, bash,was developed as part of the
GNU project and has replaced the Bourne shell, sh, for
GNU-based systems like Linux.
•All major Linux distributions, including Red Hat, Slackware,
and Caldera, ship with bash as their shreplacement.
•Although it includes C shell (cshand tcsh) and Kornshell
(ksh) features, bash retains syntax compatibility with the
Bourne shell, enabling it to run almost all Bourne shell
scripts.
•bash was written by Brian Fox of the Free Software
Foundation and is currently maintained by Chester Ramey
of Case Western Reserve University.

•Because bash is an implementation of the IEEE
POSIX 1003.2/ISO 9945.2 Shell and Tools
specification, it is extremely portable and can
be built on most UNIX systems.
•It has also been ported to QNX, Minix, OS/2,
and Windows 95/NT. Currently, only Linux
ships with the Bourne Again shell. It is
installed as /bin/bash. On most Linux systems,
it is also installed as /bin/sh.

Features of the Bourne Again Shell
•Somefeaturesthatbashincludesinadditionto
thoseoftheKornshellare:
•Namecompletionforvariablenames,usernames,
hostnames,commands,andfilenames
•Spellingcorrectionforpathnamesinthecd
command
•Arraysofunlimitedsize
•Integerarithmeticinanybasebetween2and64
Tags